Skip to content

added states and Pascal case property names #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Api/PubnubApi/EventEngine/Core/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ private async Task<IState> Transition(IEvent e) {
/// Launch the invocations associated with transitioning between states
/// </summary>
private async Task ExecuteStateChange(IState sourceState, IState targetState, IEnumerable<IEffectInvocation> 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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Api/PubnubApi/EventEngine/Core/EventEngineInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ internal interface IEffectCancelInvocation : IEffectInvocation { }
internal interface IEvent { };

internal interface IState {
public abstract IEnumerable<IEffectInvocation> onEntry { get; }
public abstract IEnumerable<IEffectInvocation> onExit { get; }
public abstract IEnumerable<IEffectInvocation> OnEntry { get; }
public abstract IEnumerable<IEffectInvocation> OnExit { get; }

/// <summary>
/// The EE transition pure function.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public class ReceiveReconnectGiveUpEvent : Core.IEvent {
}

public class DisconnectEvent : Core.IEvent {
public IEnumerable<string> Channels;
public IEnumerable<string> ChannelGroups;
}

public class ReconnectEvent : Core.IEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
}
Original file line number Diff line number Diff line change
@@ -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<string> Channels;
public IEnumerable<string> ChannelGroups;

public IEnumerable<IEffectInvocation> OnEntry { get; }
public IEnumerable<IEffectInvocation> OnExit { get; }
public Tuple<Core.IState, IEnumerable<IEffectInvocation>> Transition(IEvent e) {
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
@@ -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<string> Channels;
public IEnumerable<string> ChannelGroups;

public IEnumerable<IEffectInvocation> OnEntry { get; }
public IEnumerable<IEffectInvocation> OnExit { get; }
public Tuple<Core.IState, IEnumerable<IEffectInvocation>> Transition(IEvent e) {
switch (e) {
case Events.SubscriptionChangedEvent subscriptionChanged:
return new Tuple<Core.IState, IEnumerable<IEffectInvocation>>(
new HandshakingState() {
channels = subscriptionChanged.channels,
channelGroups = subscriptionChanged.channelGroups,
},
new[] {
new HandshakeInvocation() {
channels = subscriptionChanged.channels,
channelGroups = subscriptionChanged.channelGroups,
},
}
);
case Events.DisconnectEvent disconnectEvent:
return new Tuple<Core.IState, IEnumerable<IEffectInvocation>>(
new HandshakeStoppedState() {
Channels = disconnectEvent.Channels,
ChannelGroups = disconnectEvent.ChannelGroups
},
null
);
case Events.HandshakeReconnectGiveUpEvent handshakeReconnectGiveUpEvent:
return new Tuple<IState, IEnumerable<IEffectInvocation>>(
new HandshakeFailedState() { },
null
);

default: return null;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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<string> Channels;
public IEnumerable<string> ChannelGroups;

public IEnumerable<IEffectInvocation> OnEntry { get; }
public IEnumerable<IEffectInvocation> OnExit { get; }
public Tuple<Core.IState, IEnumerable<IEffectInvocation>> Transition(IEvent e) {
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal class HandshakingState : Core.IState {
public IEnumerable<string> channels;
public IEnumerable<string> channelGroups;

public IEnumerable<IEffectInvocation> onEntry { get; }
public IEnumerable<IEffectInvocation> onExit { get; }
public IEnumerable<IEffectInvocation> OnEntry { get; }
public IEnumerable<IEffectInvocation> OnExit { get; }
public Tuple<Core.IState, IEnumerable<IEffectInvocation>> Transition(IEvent e) {
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<string> Channels;
public IEnumerable<string> ChannelGroups;

public IEnumerable<IEffectInvocation> OnEntry { get; }
public IEnumerable<IEffectInvocation> OnExit { get; }
public Tuple<Core.IState, IEnumerable<IEffectInvocation>> Transition(IEvent e) {
throw new NotImplementedException();
}
}
}

Original file line number Diff line number Diff line change
@@ -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<string> Channels;
public IEnumerable<string> ChannelGroups;

public IEnumerable<IEffectInvocation> OnEntry { get; }
public IEnumerable<IEffectInvocation> OnExit { get; }
public Tuple<Core.IState, IEnumerable<IEffectInvocation>> Transition(IEvent e) {
throw new NotImplementedException();
}
}
}


Original file line number Diff line number Diff line change
@@ -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<string> Channels;
public IEnumerable<string> ChannelGroups;

public IEnumerable<IEffectInvocation> OnEntry { get; }
public IEnumerable<IEffectInvocation> OnExit { get; }
public Tuple<Core.IState, IEnumerable<IEffectInvocation>> Transition(IEvent e) {
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
@@ -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<string> Channels;
public IEnumerable<string> ChannelGroups;

public IEnumerable<IEffectInvocation> OnEntry { get; }
public IEnumerable<IEffectInvocation> OnExit { get; }
public Tuple<Core.IState, IEnumerable<IEffectInvocation>> Transition(IEvent e) {
throw new NotImplementedException();
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace PubnubApi.PubnubEventEngine.Subscribe.States {
internal class SubscribedState : Core.IState {
public IEnumerable<IEffectInvocation> onEntry { get; }
public IEnumerable<IEffectInvocation> onExit { get; }
public IEnumerable<IEffectInvocation> OnEntry { get; }
public IEnumerable<IEffectInvocation> OnExit { get; }
public Tuple<Core.IState, IEnumerable<IEffectInvocation>> Transition(IEvent e) {
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

namespace PubnubApi.PubnubEventEngine.Subscribe.States {
internal class UnsubscribedState : Core.IState {
public IEnumerable<IEffectInvocation> onEntry { get; }
public IEnumerable<IEffectInvocation> onExit { get; }

public IEnumerable<IEffectInvocation> OnEntry { get; }
public IEnumerable<IEffectInvocation> OnExit { get; }
public Tuple<Core.IState, IEnumerable<IEffectInvocation>> Transition(Core.IEvent e) {
switch (e) {
case Events.SubscriptionChangedEvent subscriptionChanged:
Expand Down
24 changes: 23 additions & 1 deletion src/Api/PubnubApiPCL/PubnubApiPCL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ Addressed threading issue on reading ConcurrentDictionary keys.</PackageReleaseN
<Compile Include="..\PubnubApi\Enum\ResponseType.cs">
<Link>Enum\ResponseType.cs</Link>
</Compile>
<Compile Include="..\PubnubApi\EventEngine\Core\EffectDispatcher.cs" Link="EventEngine\Core\EffectDispatcher.cs" />
<Compile Include="..\PubnubApi\EventEngine\Core\Engine.cs" Link="EventEngine\Core\Engine.cs" />
<Compile Include="..\PubnubApi\EventEngine\Core\EventEngineInterfaces.cs" Link="EventEngine\Core\EventEngineInterfaces.cs" />
<Compile Include="..\PubnubApi\EventEngine\Core\EventQueue.cs" Link="EventEngine\Core\EventQueue.cs" />
<Compile Include="..\PubnubApi\EventEngine\EffectDispatcher.cs" Link="EventEngine\EffectDispatcher.cs" />
<Compile Include="..\PubnubApi\EventEngine\EventEmitter.cs" Link="EventEngine\EventEmitter.cs" />
<Compile Include="..\PubnubApi\EventEngine\EventEngine.cs" Link="EventEngine\EventEngine.cs" />
Expand All @@ -224,6 +228,20 @@ Addressed threading issue on reading ConcurrentDictionary keys.</PackageReleaseN
<Compile Include="..\PubnubApi\EventEngine\ReceiveReconnectingEffectHandler.cs" Link="EventEngine\ReceiveReconnectingEffectHandler.cs" />
<Compile Include="..\PubnubApi\EventEngine\ReceivingEffectHandler.cs" Link="EventEngine\ReceivingEffectHandler.cs" />
<Compile Include="..\PubnubApi\EventEngine\State.cs" Link="EventEngine\State.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\Effects\HandshakeEffectHandler.cs" Link="EventEngine\Subscribe\Effects\HandshakeEffectHandler.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\Events\SubscriptionEvents.cs" Link="EventEngine\Subscribe\Events\SubscriptionEvents.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\Invocations\SubscriptionInvocations.cs" Link="EventEngine\Subscribe\Invocations\SubscriptionInvocations.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\HandshakeFailedState.cs" Link="EventEngine\Subscribe\States\HandshakeFailedState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\HandshakeReconnectingState.cs" Link="EventEngine\Subscribe\States\HandshakeReconnectingState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\HandshakeStoppedState.cs" Link="EventEngine\Subscribe\States\HandshakeStoppedState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\HandshakingState.cs" Link="EventEngine\Subscribe\States\HandshakingState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\ReceiveFailedState.cs" Link="EventEngine\Subscribe\States\ReceiveFailedState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\ReceiveReconnectingState.cs" Link="EventEngine\Subscribe\States\ReceiveReconnectingState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\ReceiveStoppedState.cs" Link="EventEngine\Subscribe\States\ReceiveStoppedState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\ReceivingState.cs" Link="EventEngine\Subscribe\States\ReceivingState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\SubscribedState.cs" Link="EventEngine\Subscribe\States\SubscribedState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\UnsubscribedState.cs" Link="EventEngine\Subscribe\States\UnsubscribedState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\SubscribeEventEngine.cs" Link="EventEngine\Subscribe\SubscribeEventEngine.cs" />
<Compile Include="..\PubnubApi\Helper\MobilePushHelper.cs" Link="Helper\MobilePushHelper.cs" />
<Compile Include="..\PubnubApi\HttpUtility\HttpUtility.cs">
<Link>HttpUtility\HttpUtility.cs</Link>
Expand Down Expand Up @@ -899,6 +917,11 @@ Addressed threading issue on reading ConcurrentDictionary keys.</PackageReleaseN
<Folder Include="EndPoint\PubSub\" />
<Folder Include="EndPoint\Presence\" />
<Folder Include="Enum\" />
<Folder Include="EventEngine\Core\" />
<Folder Include="EventEngine\Subscribe\Effects\" />
<Folder Include="EventEngine\Subscribe\Events\" />
<Folder Include="EventEngine\Subscribe\Invocations\" />
<Folder Include="EventEngine\Subscribe\States\" />
<Folder Include="HttpUtility\" />
<Folder Include="Interface\" />
<Folder Include="Log\" />
Expand All @@ -923,7 +946,6 @@ Addressed threading issue on reading ConcurrentDictionary keys.</PackageReleaseN
<Folder Include="Model\Server\" />
<Folder Include="Helper\" />
<Folder Include="JsonDataParse\" />
<Folder Include="EventEngine\" />
<Folder Include="Properties\" />
<Folder Include="Push\Mpns\" />
<Folder Include="Security\" />
Expand Down
24 changes: 23 additions & 1 deletion src/Api/PubnubApiUWP/PubnubApiUWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ Addressed threading issue on reading ConcurrentDictionary keys.</PackageReleaseN
<Compile Include="..\PubnubApi\Enum\ResponseType.cs">
<Link>Enum\ResponseType.cs</Link>
</Compile>
<Compile Include="..\PubnubApi\EventEngine\Core\EffectDispatcher.cs" Link="EventEngine\Core\EffectDispatcher.cs" />
<Compile Include="..\PubnubApi\EventEngine\Core\Engine.cs" Link="EventEngine\Core\Engine.cs" />
<Compile Include="..\PubnubApi\EventEngine\Core\EventEngineInterfaces.cs" Link="EventEngine\Core\EventEngineInterfaces.cs" />
<Compile Include="..\PubnubApi\EventEngine\Core\EventQueue.cs" Link="EventEngine\Core\EventQueue.cs" />
<Compile Include="..\PubnubApi\EventEngine\EffectDispatcher.cs" Link="EventEngine\EffectDispatcher.cs" />
<Compile Include="..\PubnubApi\EventEngine\EventEmitter.cs" Link="EventEngine\EventEmitter.cs" />
<Compile Include="..\PubnubApi\EventEngine\EventEngine.cs" Link="EventEngine\EventEngine.cs" />
Expand All @@ -341,6 +345,20 @@ Addressed threading issue on reading ConcurrentDictionary keys.</PackageReleaseN
<Compile Include="..\PubnubApi\EventEngine\ReceiveReconnectingEffectHandler.cs" Link="EventEngine\ReceiveReconnectingEffectHandler.cs" />
<Compile Include="..\PubnubApi\EventEngine\ReceivingEffectHandler.cs" Link="EventEngine\ReceivingEffectHandler.cs" />
<Compile Include="..\PubnubApi\EventEngine\State.cs" Link="EventEngine\State.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\Effects\HandshakeEffectHandler.cs" Link="EventEngine\Subscribe\Effects\HandshakeEffectHandler.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\Events\SubscriptionEvents.cs" Link="EventEngine\Subscribe\Events\SubscriptionEvents.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\Invocations\SubscriptionInvocations.cs" Link="EventEngine\Subscribe\Invocations\SubscriptionInvocations.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\HandshakeFailedState.cs" Link="EventEngine\Subscribe\States\HandshakeFailedState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\HandshakeReconnectingState.cs" Link="EventEngine\Subscribe\States\HandshakeReconnectingState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\HandshakeStoppedState.cs" Link="EventEngine\Subscribe\States\HandshakeStoppedState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\HandshakingState.cs" Link="EventEngine\Subscribe\States\HandshakingState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\ReceiveFailedState.cs" Link="EventEngine\Subscribe\States\ReceiveFailedState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\ReceiveReconnectingState.cs" Link="EventEngine\Subscribe\States\ReceiveReconnectingState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\ReceiveStoppedState.cs" Link="EventEngine\Subscribe\States\ReceiveStoppedState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\ReceivingState.cs" Link="EventEngine\Subscribe\States\ReceivingState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\SubscribedState.cs" Link="EventEngine\Subscribe\States\SubscribedState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\States\UnsubscribedState.cs" Link="EventEngine\Subscribe\States\UnsubscribedState.cs" />
<Compile Include="..\PubnubApi\EventEngine\Subscribe\SubscribeEventEngine.cs" Link="EventEngine\Subscribe\SubscribeEventEngine.cs" />
<Compile Include="..\PubnubApi\Helper\MobilePushHelper.cs" Link="Helper\MobilePushHelper.cs" />
<Compile Include="..\PubnubApi\HttpUtility\HttpUtility.cs">
<Link>HttpUtility\HttpUtility.cs</Link>
Expand Down Expand Up @@ -708,6 +726,11 @@ Addressed threading issue on reading ConcurrentDictionary keys.</PackageReleaseN
<Folder Include="EndPoint\Files\" />
<Folder Include="EndPoint\StoragePlayback\" />
<Folder Include="EndPoint\Objects\" />
<Folder Include="EventEngine\Core\" />
<Folder Include="EventEngine\Subscribe\Effects\" />
<Folder Include="EventEngine\Subscribe\Events\" />
<Folder Include="EventEngine\Subscribe\Invocations\" />
<Folder Include="EventEngine\Subscribe\States\" />
<Folder Include="Model\Consumer\DeleteMessage\" />
<Folder Include="Model\Consumer\Files\" />
<Folder Include="Model\Consumer\Objects\" />
Expand All @@ -716,7 +739,6 @@ Addressed threading issue on reading ConcurrentDictionary keys.</PackageReleaseN
<Folder Include="Model\Derived\Objects\" />
<Folder Include="JsonDataParse\" />
<Folder Include="Helper\" />
<Folder Include="EventEngine\" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
Expand Down