diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/Effects/HandshakeEffectHandler.cs b/src/Api/PubnubApi/EventEngine/Subscribe/Effects/HandshakeEffectHandler.cs index f09621caa..a28db2be5 100644 --- a/src/Api/PubnubApi/EventEngine/Subscribe/Effects/HandshakeEffectHandler.cs +++ b/src/Api/PubnubApi/EventEngine/Subscribe/Effects/HandshakeEffectHandler.cs @@ -20,12 +20,12 @@ public async Task Run(HandshakeInvocation invocation) { // TODO fix this, probably wrong :) var resp = await manager.HandshakeRequest( PNOperationType.PNSubscribeOperation, - invocation.channels.ToArray(), - invocation.channelGroups.ToArray(), + invocation.Channels.ToArray(), + invocation.ChannelGroups.ToArray(), null, null, - invocation.initialSubscribeQueryParams, - invocation.externalQueryParams + invocation.InitialSubscribeQueryParams, + invocation.ExternalQueryParams ); if (!resp.Item2.Error) { diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/Events/SubscriptionEvents.cs b/src/Api/PubnubApi/EventEngine/Subscribe/Events/SubscriptionEvents.cs index 86295c0b6..e2a174173 100644 --- a/src/Api/PubnubApi/EventEngine/Subscribe/Events/SubscriptionEvents.cs +++ b/src/Api/PubnubApi/EventEngine/Subscribe/Events/SubscriptionEvents.cs @@ -2,14 +2,14 @@ namespace PubnubApi.PubnubEventEngine.Subscribe.Events { public class SubscriptionChangedEvent : Core.IEvent { - public IEnumerable channels; - public IEnumerable channelGroups; + public IEnumerable Channels; + public IEnumerable ChannelGroups; } public class SubscriptionRestoredEvent : Core.IEvent { - public IEnumerable channels; - public IEnumerable channelGroups; - public SubscriptionCursor cursor; + public IEnumerable Channels; + public IEnumerable ChannelGroups; + public SubscriptionCursor Cursor; } public class HandshakeSuccessEvent : Core.IEvent { @@ -22,6 +22,8 @@ public class HandshakeFailureEvent : Core.IEvent { } public class HandshakeReconnectSuccessEvent : HandshakeSuccessEvent { + public IEnumerable Channels; + public IEnumerable ChannelGroups; } public class HandshakeReconnectFailureEvent : HandshakeFailureEvent { @@ -31,6 +33,8 @@ public class HandshakeReconnectRetryEvent : Core.IEvent { } public class HandshakeReconnectGiveUpEvent : Core.IEvent { + public IEnumerable Channels; + public IEnumerable ChannelGroups; // TODO status or reason? public PNStatus status; } @@ -65,5 +69,7 @@ public class DisconnectEvent : Core.IEvent { } public class ReconnectEvent : Core.IEvent { + public IEnumerable Channels; + public IEnumerable ChannelGroups; } } \ No newline at end of file diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/Invocations/SubscriptionInvocations.cs b/src/Api/PubnubApi/EventEngine/Subscribe/Invocations/SubscriptionInvocations.cs index cec835b12..39e615b2e 100644 --- a/src/Api/PubnubApi/EventEngine/Subscribe/Invocations/SubscriptionInvocations.cs +++ b/src/Api/PubnubApi/EventEngine/Subscribe/Invocations/SubscriptionInvocations.cs @@ -7,24 +7,34 @@ internal class EmitMessagesInvocation : Core.IEffectInvocation { } internal class EmitStatusInvocation : Core.IEffectInvocation { - + public IEnumerable Channels; + public IEnumerable ChannelGroups; } internal class HandshakeInvocation : Core.IEffectInvocation { - public IEnumerable channels; - public IEnumerable channelGroups; - public Dictionary initialSubscribeQueryParams = new Dictionary(); - public Dictionary externalQueryParams = new Dictionary(); + public IEnumerable Channels; + public IEnumerable ChannelGroups; + public Dictionary InitialSubscribeQueryParams = new Dictionary(); + public Dictionary ExternalQueryParams = new Dictionary(); } - internal class ReceiveMessagesInvocation : Core.IEffectInvocation { } + internal class ReceiveMessagesInvocation : Core.IEffectInvocation + { + public IEnumerable Channels; + public IEnumerable ChannelGroups; + } internal class CancelReceiveMessagesInvocation : ReceiveMessagesInvocation, Core.IEffectCancelInvocation { } internal class HandshakeCancelInvocation : HandshakeInvocation, Core.IEffectCancelInvocation { } //internal class ReconnectInvocation : Core.IEffectInvocation { } - internal class HandshakeReconnectInvocation: Core.IEffectInvocation { } + internal class HandshakeReconnectInvocation: Core.IEffectInvocation + { + public IEnumerable Channels; + public IEnumerable ChannelGroups; + } + internal class CancelHandshakeReconnectInvocation: HandshakeReconnectInvocation, Core.IEffectCancelInvocation { } internal class ReceiveReconnectInvocation: Core.IEffectInvocation { } diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakeFailedState.cs b/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakeFailedState.cs index 1ed4edbec..816d80fc2 100644 --- a/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakeFailedState.cs +++ b/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakeFailedState.cs @@ -12,7 +12,49 @@ internal class HandshakeFailedState : Core.IState { public IEnumerable OnEntry { get; } public IEnumerable OnExit { get; } public Tuple> Transition(IEvent e) { - throw new NotImplementedException(); + switch (e) { + case Events.SubscriptionChangedEvent subscriptionChanged: + return new Tuple>( + new HandshakingState() { + Channels = subscriptionChanged.Channels, + ChannelGroups = subscriptionChanged.ChannelGroups, + }, + new[] { + new HandshakeInvocation() { + Channels = subscriptionChanged.Channels, + ChannelGroups = subscriptionChanged.ChannelGroups, + }, + } + ); + case Events.ReconnectEvent reconnect: + return new Tuple>( + new HandshakingState() { + Channels = reconnect.Channels, + ChannelGroups = reconnect.ChannelGroups, + }, + new[] { + new HandshakeInvocation() { + Channels = reconnect.Channels, + ChannelGroups = reconnect.ChannelGroups, + }, + } + ); + case Events.SubscriptionRestoredEvent subscriptionRestored: + return new Tuple>( + new ReceivingState() { + Channels = subscriptionRestored.Channels, + ChannelGroups = subscriptionRestored.ChannelGroups + }, + new[] { + new ReceiveMessagesInvocation() { + Channels = subscriptionRestored.Channels, + ChannelGroups = subscriptionRestored.ChannelGroups, + }, + } + ); + + default: return null; + } } } } diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakeReconnectingState.cs b/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakeReconnectingState.cs index dfe2561c1..26aba2e9c 100644 --- a/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakeReconnectingState.cs +++ b/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakeReconnectingState.cs @@ -16,27 +16,51 @@ internal class HandshakeReconnectingState : Core.IState { case Events.SubscriptionChangedEvent subscriptionChanged: return new Tuple>( new HandshakingState() { - channels = subscriptionChanged.channels, - channelGroups = subscriptionChanged.channelGroups, + Channels = subscriptionChanged.Channels, + ChannelGroups = subscriptionChanged.ChannelGroups, }, new[] { new HandshakeInvocation() { - channels = subscriptionChanged.channels, - channelGroups = subscriptionChanged.channelGroups, + Channels = subscriptionChanged.Channels, + ChannelGroups = subscriptionChanged.ChannelGroups, }, } ); - case Events.DisconnectEvent disconnectEvent: + case Events.DisconnectEvent disconnect: return new Tuple>( new HandshakeStoppedState() { - Channels = disconnectEvent.Channels, - ChannelGroups = disconnectEvent.ChannelGroups + Channels = disconnect.Channels, + ChannelGroups = disconnect.ChannelGroups }, null ); - case Events.HandshakeReconnectGiveUpEvent handshakeReconnectGiveUpEvent: + case Events.HandshakeReconnectGiveUpEvent handshakeReconnectGiveUp: return new Tuple>( - new HandshakeFailedState() { }, + new HandshakeFailedState() { + Channels = handshakeReconnectGiveUp.Channels, + ChannelGroups = handshakeReconnectGiveUp.ChannelGroups + }, + null + ); + case Events.HandshakeReconnectSuccessEvent handshakeReconnectSuccess: + return new Tuple>( + new ReceivingState() { + Channels = handshakeReconnectSuccess.Channels, + ChannelGroups = handshakeReconnectSuccess.ChannelGroups + }, + new[] { + new EmitStatusInvocation() { + Channels = handshakeReconnectSuccess.Channels, + ChannelGroups = handshakeReconnectSuccess.ChannelGroups, + }, + } + ); + case Events.SubscriptionRestoredEvent subscriptionRestored: + return new Tuple>( + new HandshakeFailedState() { + Channels = subscriptionRestored.Channels, + ChannelGroups = subscriptionRestored.ChannelGroups + }, null ); diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakingState.cs b/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakingState.cs index 29aa611b2..a17469e96 100644 --- a/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakingState.cs +++ b/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakingState.cs @@ -5,8 +5,8 @@ namespace PubnubApi.PubnubEventEngine.Subscribe.States { internal class HandshakingState : Core.IState { - public IEnumerable channels; - public IEnumerable channelGroups; + public IEnumerable Channels; + public IEnumerable ChannelGroups; public IEnumerable OnEntry { get; } public IEnumerable OnExit { get; } diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/States/UnsubscribedState.cs b/src/Api/PubnubApi/EventEngine/Subscribe/States/UnsubscribedState.cs index f8a45cd74..7c9a7c386 100644 --- a/src/Api/PubnubApi/EventEngine/Subscribe/States/UnsubscribedState.cs +++ b/src/Api/PubnubApi/EventEngine/Subscribe/States/UnsubscribedState.cs @@ -12,13 +12,13 @@ internal class UnsubscribedState : Core.IState { case Events.SubscriptionChangedEvent subscriptionChanged: return new Tuple>( new HandshakingState() { - channels = subscriptionChanged.channels, - channelGroups = subscriptionChanged.channelGroups, + Channels = subscriptionChanged.Channels, + ChannelGroups = subscriptionChanged.ChannelGroups, }, new[] { new HandshakeInvocation() { - channels = subscriptionChanged.channels, - channelGroups = subscriptionChanged.channelGroups, + Channels = subscriptionChanged.Channels, + ChannelGroups = subscriptionChanged.ChannelGroups, }, } );