diff --git a/src/Api/PubnubApi/EventEngine/Core/Engine.cs b/src/Api/PubnubApi/EventEngine/Core/Engine.cs index 1a26037d7..d257ff3c8 100644 --- a/src/Api/PubnubApi/EventEngine/Core/Engine.cs +++ b/src/Api/PubnubApi/EventEngine/Core/Engine.cs @@ -41,13 +41,13 @@ private async Task Transition(IEvent e) { /// Launch the invocations associated with transitioning between states /// private async Task ExecuteStateChange(IState sourceState, IState targetState, IEnumerable invocations) { - foreach (var effectInvocation in sourceState.onExit) { + foreach (var effectInvocation in sourceState.OnExit) { await dispatcher.Dispatch(effectInvocation); } foreach (var effectInvocation in invocations) { await dispatcher.Dispatch(effectInvocation); } - foreach (var effectInvocation in targetState.onEntry) { + foreach (var effectInvocation in targetState.OnEntry) { await dispatcher.Dispatch(effectInvocation); } } diff --git a/src/Api/PubnubApi/EventEngine/Core/EventEngineInterfaces.cs b/src/Api/PubnubApi/EventEngine/Core/EventEngineInterfaces.cs index 61d2ea495..201f027de 100644 --- a/src/Api/PubnubApi/EventEngine/Core/EventEngineInterfaces.cs +++ b/src/Api/PubnubApi/EventEngine/Core/EventEngineInterfaces.cs @@ -17,8 +17,8 @@ internal interface IEffectCancelInvocation : IEffectInvocation { } internal interface IEvent { }; internal interface IState { - public abstract IEnumerable onEntry { get; } - public abstract IEnumerable onExit { get; } + public abstract IEnumerable OnEntry { get; } + public abstract IEnumerable OnExit { get; } /// /// The EE transition pure function. diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/Events/SubscriptionEvents.cs b/src/Api/PubnubApi/EventEngine/Subscribe/Events/SubscriptionEvents.cs index 221fa68bb..86295c0b6 100644 --- a/src/Api/PubnubApi/EventEngine/Subscribe/Events/SubscriptionEvents.cs +++ b/src/Api/PubnubApi/EventEngine/Subscribe/Events/SubscriptionEvents.cs @@ -60,6 +60,8 @@ public class ReceiveReconnectGiveUpEvent : Core.IEvent { } public class DisconnectEvent : Core.IEvent { + public IEnumerable Channels; + public IEnumerable ChannelGroups; } public class ReconnectEvent : Core.IEvent { diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/Invocations/SubscriptionInvocations.cs b/src/Api/PubnubApi/EventEngine/Subscribe/Invocations/SubscriptionInvocations.cs index 2f33d4928..cec835b12 100644 --- a/src/Api/PubnubApi/EventEngine/Subscribe/Invocations/SubscriptionInvocations.cs +++ b/src/Api/PubnubApi/EventEngine/Subscribe/Invocations/SubscriptionInvocations.cs @@ -23,7 +23,11 @@ internal class CancelReceiveMessagesInvocation : ReceiveMessagesInvocation, Core internal class HandshakeCancelInvocation : HandshakeInvocation, Core.IEffectCancelInvocation { } - internal class ReconnectInvocation : Core.IEffectInvocation { } + //internal class ReconnectInvocation : Core.IEffectInvocation { } + internal class HandshakeReconnectInvocation: Core.IEffectInvocation { } + internal class CancelHandshakeReconnectInvocation: HandshakeReconnectInvocation, Core.IEffectCancelInvocation { } - internal class CancelReconnectInvocation : ReconnectInvocation, Core.IEffectCancelInvocation { } + internal class ReceiveReconnectInvocation: Core.IEffectInvocation { } + internal class CancelReceiveReconnectInvocation: ReceiveReconnectInvocation, Core.IEffectCancelInvocation { } + //internal class CancelReconnectInvocation : ReconnectInvocation, Core.IEffectCancelInvocation { } } \ No newline at end of file diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakeFailedState.cs b/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakeFailedState.cs new file mode 100644 index 000000000..1ed4edbec --- /dev/null +++ b/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakeFailedState.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using PubnubApi.PubnubEventEngine.Core; +using PubnubApi.PubnubEventEngine.Subscribe.Invocations; + +namespace PubnubApi.PubnubEventEngine.Subscribe.States { + internal class HandshakeFailedState : Core.IState { + + public IEnumerable Channels; + public IEnumerable ChannelGroups; + + public IEnumerable OnEntry { get; } + public IEnumerable OnExit { get; } + public Tuple> Transition(IEvent e) { + throw new NotImplementedException(); + } + } +} diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakeReconnectingState.cs b/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakeReconnectingState.cs new file mode 100644 index 000000000..dfe2561c1 --- /dev/null +++ b/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakeReconnectingState.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using PubnubApi.PubnubEventEngine.Core; +using PubnubApi.PubnubEventEngine.Subscribe.Invocations; + +namespace PubnubApi.PubnubEventEngine.Subscribe.States { + internal class HandshakeReconnectingState : Core.IState { + + public IEnumerable Channels; + public IEnumerable ChannelGroups; + + public IEnumerable OnEntry { get; } + public IEnumerable OnExit { get; } + public Tuple> Transition(IEvent e) { + 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.DisconnectEvent disconnectEvent: + return new Tuple>( + new HandshakeStoppedState() { + Channels = disconnectEvent.Channels, + ChannelGroups = disconnectEvent.ChannelGroups + }, + null + ); + case Events.HandshakeReconnectGiveUpEvent handshakeReconnectGiveUpEvent: + return new Tuple>( + new HandshakeFailedState() { }, + null + ); + + default: return null; + } + } + } +} \ No newline at end of file diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakeStoppedState.cs b/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakeStoppedState.cs new file mode 100644 index 000000000..9774bc6cb --- /dev/null +++ b/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakeStoppedState.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using PubnubApi.PubnubEventEngine.Core; +using PubnubApi.PubnubEventEngine.Subscribe.Invocations; + +namespace PubnubApi.PubnubEventEngine.Subscribe.States { + internal class HandshakeStoppedState : Core.IState { + + public IEnumerable Channels; + public IEnumerable ChannelGroups; + + public IEnumerable OnEntry { get; } + public IEnumerable OnExit { get; } + public Tuple> Transition(IEvent e) { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakingState.cs b/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakingState.cs index cae98bd0a..29aa611b2 100644 --- a/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakingState.cs +++ b/src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakingState.cs @@ -8,8 +8,8 @@ internal class HandshakingState : Core.IState { public IEnumerable channels; public IEnumerable channelGroups; - public IEnumerable onEntry { get; } - public IEnumerable onExit { get; } + public IEnumerable OnEntry { get; } + public IEnumerable OnExit { get; } public Tuple> Transition(IEvent e) { throw new NotImplementedException(); } diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/States/ReceiveFailedState.cs b/src/Api/PubnubApi/EventEngine/Subscribe/States/ReceiveFailedState.cs new file mode 100644 index 000000000..41c4be2ee --- /dev/null +++ b/src/Api/PubnubApi/EventEngine/Subscribe/States/ReceiveFailedState.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using PubnubApi.PubnubEventEngine.Core; +using PubnubApi.PubnubEventEngine.Subscribe.Invocations; + +namespace PubnubApi.PubnubEventEngine.Subscribe.States { + internal class ReceiveFailedState : Core.IState { + + public IEnumerable Channels; + public IEnumerable ChannelGroups; + + public IEnumerable OnEntry { get; } + public IEnumerable OnExit { get; } + public Tuple> Transition(IEvent e) { + throw new NotImplementedException(); + } + } +} + diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/States/ReceiveReconnectingState.cs b/src/Api/PubnubApi/EventEngine/Subscribe/States/ReceiveReconnectingState.cs new file mode 100644 index 000000000..2a16d3c02 --- /dev/null +++ b/src/Api/PubnubApi/EventEngine/Subscribe/States/ReceiveReconnectingState.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using PubnubApi.PubnubEventEngine.Core; +using PubnubApi.PubnubEventEngine.Subscribe.Invocations; + +namespace PubnubApi.PubnubEventEngine.Subscribe.States { + internal class ReceiveReconnectingState : Core.IState { + + public IEnumerable Channels; + public IEnumerable ChannelGroups; + + public IEnumerable OnEntry { get; } + public IEnumerable OnExit { get; } + public Tuple> Transition(IEvent e) { + throw new NotImplementedException(); + } + } +} + + diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/States/ReceiveStoppedState.cs b/src/Api/PubnubApi/EventEngine/Subscribe/States/ReceiveStoppedState.cs new file mode 100644 index 000000000..0d925e43e --- /dev/null +++ b/src/Api/PubnubApi/EventEngine/Subscribe/States/ReceiveStoppedState.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using PubnubApi.PubnubEventEngine.Core; +using PubnubApi.PubnubEventEngine.Subscribe.Invocations; + +namespace PubnubApi.PubnubEventEngine.Subscribe.States { + internal class ReceiveStoppedState : Core.IState { + + public IEnumerable Channels; + public IEnumerable ChannelGroups; + + public IEnumerable OnEntry { get; } + public IEnumerable OnExit { get; } + public Tuple> Transition(IEvent e) { + throw new NotImplementedException(); + } + } +} diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/States/ReceivingState.cs b/src/Api/PubnubApi/EventEngine/Subscribe/States/ReceivingState.cs new file mode 100644 index 000000000..2208f539a --- /dev/null +++ b/src/Api/PubnubApi/EventEngine/Subscribe/States/ReceivingState.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using PubnubApi.PubnubEventEngine.Core; +using PubnubApi.PubnubEventEngine.Subscribe.Invocations; + +namespace PubnubApi.PubnubEventEngine.Subscribe.States { + internal class ReceivingState : Core.IState { + + public IEnumerable Channels; + public IEnumerable ChannelGroups; + + public IEnumerable OnEntry { get; } + public IEnumerable OnExit { get; } + public Tuple> Transition(IEvent e) { + throw new NotImplementedException(); + } + } +} + diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/States/SubscribedState.cs b/src/Api/PubnubApi/EventEngine/Subscribe/States/SubscribedState.cs index d00659631..39de39a23 100644 --- a/src/Api/PubnubApi/EventEngine/Subscribe/States/SubscribedState.cs +++ b/src/Api/PubnubApi/EventEngine/Subscribe/States/SubscribedState.cs @@ -4,8 +4,8 @@ namespace PubnubApi.PubnubEventEngine.Subscribe.States { internal class SubscribedState : Core.IState { - public IEnumerable onEntry { get; } - public IEnumerable onExit { get; } + public IEnumerable OnEntry { get; } + public IEnumerable OnExit { get; } public Tuple> Transition(IEvent e) { throw new NotImplementedException(); } diff --git a/src/Api/PubnubApi/EventEngine/Subscribe/States/UnsubscribedState.cs b/src/Api/PubnubApi/EventEngine/Subscribe/States/UnsubscribedState.cs index 857375ceb..f8a45cd74 100644 --- a/src/Api/PubnubApi/EventEngine/Subscribe/States/UnsubscribedState.cs +++ b/src/Api/PubnubApi/EventEngine/Subscribe/States/UnsubscribedState.cs @@ -5,9 +5,8 @@ namespace PubnubApi.PubnubEventEngine.Subscribe.States { internal class UnsubscribedState : Core.IState { - public IEnumerable onEntry { get; } - public IEnumerable onExit { get; } - + public IEnumerable OnEntry { get; } + public IEnumerable OnExit { get; } public Tuple> Transition(Core.IEvent e) { switch (e) { case Events.SubscriptionChangedEvent subscriptionChanged: diff --git a/src/Api/PubnubApiPCL/PubnubApiPCL.csproj b/src/Api/PubnubApiPCL/PubnubApiPCL.csproj index 066bf9e34..fd3bba484 100644 --- a/src/Api/PubnubApiPCL/PubnubApiPCL.csproj +++ b/src/Api/PubnubApiPCL/PubnubApiPCL.csproj @@ -214,6 +214,10 @@ Addressed threading issue on reading ConcurrentDictionary keys. Enum\ResponseType.cs + + + + @@ -224,6 +228,20 @@ Addressed threading issue on reading ConcurrentDictionary keys. + + + + + + + + + + + + + + HttpUtility\HttpUtility.cs @@ -899,6 +917,11 @@ Addressed threading issue on reading ConcurrentDictionary keys. + + + + + @@ -923,7 +946,6 @@ Addressed threading issue on reading ConcurrentDictionary keys. - diff --git a/src/Api/PubnubApiUWP/PubnubApiUWP.csproj b/src/Api/PubnubApiUWP/PubnubApiUWP.csproj index 609a09597..5646458ad 100644 --- a/src/Api/PubnubApiUWP/PubnubApiUWP.csproj +++ b/src/Api/PubnubApiUWP/PubnubApiUWP.csproj @@ -331,6 +331,10 @@ Addressed threading issue on reading ConcurrentDictionary keys. Enum\ResponseType.cs + + + + @@ -341,6 +345,20 @@ Addressed threading issue on reading ConcurrentDictionary keys. + + + + + + + + + + + + + + HttpUtility\HttpUtility.cs @@ -708,6 +726,11 @@ Addressed threading issue on reading ConcurrentDictionary keys. + + + + + @@ -716,7 +739,6 @@ Addressed threading issue on reading ConcurrentDictionary keys. - 14.0