-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add interfaces for publicly facing classes
- Loading branch information
1 parent
8f57edf
commit cca23d2
Showing
10 changed files
with
266 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Supabase.Realtime.Interfaces | ||
{ | ||
public interface IRealtimeChannel | ||
{ | ||
bool HasJoinedOnce { get; } | ||
bool IsClosed { get; } | ||
bool IsErrored { get; } | ||
bool IsJoined { get; } | ||
bool IsJoining { get; } | ||
bool IsLeaving { get; } | ||
ChannelOptions Options { get; } | ||
Channel.ChannelState State { get; } | ||
string Topic { get; } | ||
|
||
event EventHandler<ChannelStateChangedEventArgs> OnClose; | ||
event EventHandler<SocketResponseEventArgs> OnDelete; | ||
event EventHandler<ChannelStateChangedEventArgs> OnError; | ||
event EventHandler<SocketResponseEventArgs> OnInsert; | ||
event EventHandler<SocketResponseEventArgs> OnMessage; | ||
event EventHandler<SocketResponseEventArgs> OnUpdate; | ||
event EventHandler<ChannelStateChangedEventArgs> StateChanged; | ||
|
||
void Push(string eventName, object payload, int timeoutMs = 10000); | ||
void Rejoin(int timeoutMs = 10000); | ||
Task<IRealtimeChannel> Subscribe(int timeoutMs = 10000); | ||
void Unsubscribe(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Net.WebSockets; | ||
using System.Threading.Tasks; | ||
|
||
namespace Supabase.Realtime.Interfaces | ||
{ | ||
public interface IRealtimeClient<TSocket, TChannel> | ||
where TSocket: IRealtimeSocket | ||
where TChannel: IRealtimeChannel | ||
{ | ||
ClientOptions Options { get; } | ||
JsonSerializerSettings SerializerSettings { get; } | ||
IRealtimeSocket? Socket { get; } | ||
ReadOnlyDictionary<string, TChannel> Subscriptions { get; } | ||
|
||
event EventHandler<SocketStateChangedEventArgs> OnClose; | ||
event EventHandler<SocketStateChangedEventArgs> OnError; | ||
event EventHandler<SocketStateChangedEventArgs> OnMessage; | ||
event EventHandler<SocketStateChangedEventArgs> OnOpen; | ||
|
||
Channel Channel(string database = "realtime", string? schema = null, string? table = null, string? column = null, string? value = null, Dictionary<string, string>? parameters = null); | ||
IRealtimeClient<TSocket, TChannel> Connect(Action<IRealtimeClient<TSocket, TChannel>>? callback = null); | ||
Task<IRealtimeClient<TSocket, TChannel>> ConnectAsync(); | ||
IRealtimeClient<TSocket, TChannel> Disconnect(WebSocketCloseStatus code = WebSocketCloseStatus.NormalClosure, string reason = "Programmatic Disconnect"); | ||
void Remove(TChannel channel); | ||
void SetAuth(string jwt); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
|
||
namespace Supabase.Realtime.Interfaces | ||
{ | ||
public interface IRealtimePush<TChannel, TSocketResponse> | ||
where TChannel : IRealtimeChannel | ||
where TSocketResponse: IRealtimeSocketResponse | ||
{ | ||
TChannel Channel { get; } | ||
string EventName { get; } | ||
bool IsSent { get; } | ||
SocketRequest? Message { get; } | ||
object? Payload { get; } | ||
string? Ref { get; } | ||
IRealtimeSocketResponse? Response { get; } | ||
|
||
event EventHandler<SocketResponseEventArgs>? OnMessage; | ||
event EventHandler? OnTimeout; | ||
|
||
void Resend(int timeoutMs = 10000); | ||
void Send(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Net.WebSockets; | ||
|
||
namespace Supabase.Realtime.Interfaces | ||
{ | ||
public interface IRealtimeSocket | ||
{ | ||
bool IsConnected { get; } | ||
|
||
event EventHandler<SocketResponseEventArgs> OnHeartbeat; | ||
event EventHandler<SocketResponseEventArgs> OnMessage; | ||
event EventHandler<SocketStateChangedEventArgs> StateChanged; | ||
|
||
void Connect(); | ||
void Disconnect(WebSocketCloseStatus code = WebSocketCloseStatus.NormalClosure, string reason = ""); | ||
string MakeMsgRef(); | ||
void Push(SocketRequest data); | ||
string ReplyEventName(string msgRef); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Postgrest.Models; | ||
|
||
namespace Supabase.Realtime.Interfaces | ||
{ | ||
public interface IRealtimeSocketResponse | ||
{ | ||
string? _event { get; set; } | ||
Constants.EventType Event { get; } | ||
SocketResponsePayload? Payload { get; set; } | ||
string? Ref { get; set; } | ||
string? Topic { get; set; } | ||
|
||
T? Model<T>() where T : BaseModel, new(); | ||
T? OldModel<T>() where T : BaseModel, new(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.