From 9dce6adf0c81ea33365a99455f73e0517558f3ed Mon Sep 17 00:00:00 2001 From: smanickam Date: Fri, 6 Nov 2020 09:14:45 -0500 Subject: [PATCH] First crack at group grain --- .../Grains/IGroupGrain.cs | 34 +++++++++++++++++++ .../Observers/IServerObserver.cs | 6 +++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/Orleans.AspNetCore.SignalR.Core/Grains/IGroupGrain.cs diff --git a/src/Orleans.AspNetCore.SignalR.Core/Grains/IGroupGrain.cs b/src/Orleans.AspNetCore.SignalR.Core/Grains/IGroupGrain.cs new file mode 100644 index 0000000..5f7e64c --- /dev/null +++ b/src/Orleans.AspNetCore.SignalR.Core/Grains/IGroupGrain.cs @@ -0,0 +1,34 @@ +using Orleans.AspNetCore.SignalR.Observers; +using System.Threading.Tasks; + +namespace Orleans.AspNetCore.SignalR.Grains +{ + public interface IGroupGrain : IGrainWithStringKey + { + /// + /// Adds server to group + /// + /// The server + /// + Task AddServer(IServerObserver server); + + /// + /// This method is used to confirm the server is still up. The grain implementation will + /// expect this method to be invoked after is calls 'IServerObserver.SendToGroup'. IF this + /// isn't called after a certain amount of time, the server will be removed from the list of + /// servers that hold a connection to this group + /// + /// + /// + Task ConfirmConnection(IServerObserver server); + + /// + /// Removes server from group + /// + /// the server + /// + Task RemoveServer(IServerObserver server); + + Task SendMessage(string method, params object[] args); + } +} \ No newline at end of file diff --git a/src/Orleans.AspNetCore.SignalR.Core/Observers/IServerObserver.cs b/src/Orleans.AspNetCore.SignalR.Core/Observers/IServerObserver.cs index aa3026d..57e9d36 100644 --- a/src/Orleans.AspNetCore.SignalR.Core/Observers/IServerObserver.cs +++ b/src/Orleans.AspNetCore.SignalR.Core/Observers/IServerObserver.cs @@ -6,5 +6,9 @@ namespace Orleans.AspNetCore.SignalR.Observers public interface IServerObserver : IGrainObserver { void SendHubConnection(string connectionId, Immutable message); + + void SendToGroup(string groupId, Immutable message); + + void SendToUser(string userId, Immutable message); } -} +} \ No newline at end of file