Skip to content

Commit 5b8de6c

Browse files
added states and Pascal case property names (#171)
* added states and Pascal case property names
1 parent 84af23d commit 5b8de6c

16 files changed

+223
-15
lines changed

src/Api/PubnubApi/EventEngine/Core/Engine.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ private async Task<IState> Transition(IEvent e) {
4141
/// Launch the invocations associated with transitioning between states
4242
/// </summary>
4343
private async Task ExecuteStateChange(IState sourceState, IState targetState, IEnumerable<IEffectInvocation> invocations) {
44-
foreach (var effectInvocation in sourceState.onExit) {
44+
foreach (var effectInvocation in sourceState.OnExit) {
4545
await dispatcher.Dispatch(effectInvocation);
4646
}
4747
foreach (var effectInvocation in invocations) {
4848
await dispatcher.Dispatch(effectInvocation);
4949
}
50-
foreach (var effectInvocation in targetState.onEntry) {
50+
foreach (var effectInvocation in targetState.OnEntry) {
5151
await dispatcher.Dispatch(effectInvocation);
5252
}
5353
}

src/Api/PubnubApi/EventEngine/Core/EventEngineInterfaces.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ internal interface IEffectCancelInvocation : IEffectInvocation { }
1717
internal interface IEvent { };
1818

1919
internal interface IState {
20-
public abstract IEnumerable<IEffectInvocation> onEntry { get; }
21-
public abstract IEnumerable<IEffectInvocation> onExit { get; }
20+
public abstract IEnumerable<IEffectInvocation> OnEntry { get; }
21+
public abstract IEnumerable<IEffectInvocation> OnExit { get; }
2222

2323
/// <summary>
2424
/// The EE transition pure function.

src/Api/PubnubApi/EventEngine/Subscribe/Events/SubscriptionEvents.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public class ReceiveReconnectGiveUpEvent : Core.IEvent {
6060
}
6161

6262
public class DisconnectEvent : Core.IEvent {
63+
public IEnumerable<string> Channels;
64+
public IEnumerable<string> ChannelGroups;
6365
}
6466

6567
public class ReconnectEvent : Core.IEvent {

src/Api/PubnubApi/EventEngine/Subscribe/Invocations/SubscriptionInvocations.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ internal class CancelReceiveMessagesInvocation : ReceiveMessagesInvocation, Core
2323

2424
internal class HandshakeCancelInvocation : HandshakeInvocation, Core.IEffectCancelInvocation { }
2525

26-
internal class ReconnectInvocation : Core.IEffectInvocation { }
26+
//internal class ReconnectInvocation : Core.IEffectInvocation { }
27+
internal class HandshakeReconnectInvocation: Core.IEffectInvocation { }
28+
internal class CancelHandshakeReconnectInvocation: HandshakeReconnectInvocation, Core.IEffectCancelInvocation { }
2729

28-
internal class CancelReconnectInvocation : ReconnectInvocation, Core.IEffectCancelInvocation { }
30+
internal class ReceiveReconnectInvocation: Core.IEffectInvocation { }
31+
internal class CancelReceiveReconnectInvocation: ReceiveReconnectInvocation, Core.IEffectCancelInvocation { }
32+
//internal class CancelReconnectInvocation : ReconnectInvocation, Core.IEffectCancelInvocation { }
2933
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using PubnubApi.PubnubEventEngine.Core;
4+
using PubnubApi.PubnubEventEngine.Subscribe.Invocations;
5+
6+
namespace PubnubApi.PubnubEventEngine.Subscribe.States {
7+
internal class HandshakeFailedState : Core.IState {
8+
9+
public IEnumerable<string> Channels;
10+
public IEnumerable<string> ChannelGroups;
11+
12+
public IEnumerable<IEffectInvocation> OnEntry { get; }
13+
public IEnumerable<IEffectInvocation> OnExit { get; }
14+
public Tuple<Core.IState, IEnumerable<IEffectInvocation>> Transition(IEvent e) {
15+
throw new NotImplementedException();
16+
}
17+
}
18+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using PubnubApi.PubnubEventEngine.Core;
4+
using PubnubApi.PubnubEventEngine.Subscribe.Invocations;
5+
6+
namespace PubnubApi.PubnubEventEngine.Subscribe.States {
7+
internal class HandshakeReconnectingState : Core.IState {
8+
9+
public IEnumerable<string> Channels;
10+
public IEnumerable<string> ChannelGroups;
11+
12+
public IEnumerable<IEffectInvocation> OnEntry { get; }
13+
public IEnumerable<IEffectInvocation> OnExit { get; }
14+
public Tuple<Core.IState, IEnumerable<IEffectInvocation>> Transition(IEvent e) {
15+
switch (e) {
16+
case Events.SubscriptionChangedEvent subscriptionChanged:
17+
return new Tuple<Core.IState, IEnumerable<IEffectInvocation>>(
18+
new HandshakingState() {
19+
channels = subscriptionChanged.channels,
20+
channelGroups = subscriptionChanged.channelGroups,
21+
},
22+
new[] {
23+
new HandshakeInvocation() {
24+
channels = subscriptionChanged.channels,
25+
channelGroups = subscriptionChanged.channelGroups,
26+
},
27+
}
28+
);
29+
case Events.DisconnectEvent disconnectEvent:
30+
return new Tuple<Core.IState, IEnumerable<IEffectInvocation>>(
31+
new HandshakeStoppedState() {
32+
Channels = disconnectEvent.Channels,
33+
ChannelGroups = disconnectEvent.ChannelGroups
34+
},
35+
null
36+
);
37+
case Events.HandshakeReconnectGiveUpEvent handshakeReconnectGiveUpEvent:
38+
return new Tuple<IState, IEnumerable<IEffectInvocation>>(
39+
new HandshakeFailedState() { },
40+
null
41+
);
42+
43+
default: return null;
44+
}
45+
}
46+
}
47+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using PubnubApi.PubnubEventEngine.Core;
4+
using PubnubApi.PubnubEventEngine.Subscribe.Invocations;
5+
6+
namespace PubnubApi.PubnubEventEngine.Subscribe.States {
7+
internal class HandshakeStoppedState : Core.IState {
8+
9+
public IEnumerable<string> Channels;
10+
public IEnumerable<string> ChannelGroups;
11+
12+
public IEnumerable<IEffectInvocation> OnEntry { get; }
13+
public IEnumerable<IEffectInvocation> OnExit { get; }
14+
public Tuple<Core.IState, IEnumerable<IEffectInvocation>> Transition(IEvent e) {
15+
throw new NotImplementedException();
16+
}
17+
}
18+
}

src/Api/PubnubApi/EventEngine/Subscribe/States/HandshakingState.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ internal class HandshakingState : Core.IState {
88
public IEnumerable<string> channels;
99
public IEnumerable<string> channelGroups;
1010

11-
public IEnumerable<IEffectInvocation> onEntry { get; }
12-
public IEnumerable<IEffectInvocation> onExit { get; }
11+
public IEnumerable<IEffectInvocation> OnEntry { get; }
12+
public IEnumerable<IEffectInvocation> OnExit { get; }
1313
public Tuple<Core.IState, IEnumerable<IEffectInvocation>> Transition(IEvent e) {
1414
throw new NotImplementedException();
1515
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using PubnubApi.PubnubEventEngine.Core;
4+
using PubnubApi.PubnubEventEngine.Subscribe.Invocations;
5+
6+
namespace PubnubApi.PubnubEventEngine.Subscribe.States {
7+
internal class ReceiveFailedState : Core.IState {
8+
9+
public IEnumerable<string> Channels;
10+
public IEnumerable<string> ChannelGroups;
11+
12+
public IEnumerable<IEffectInvocation> OnEntry { get; }
13+
public IEnumerable<IEffectInvocation> OnExit { get; }
14+
public Tuple<Core.IState, IEnumerable<IEffectInvocation>> Transition(IEvent e) {
15+
throw new NotImplementedException();
16+
}
17+
}
18+
}
19+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using PubnubApi.PubnubEventEngine.Core;
4+
using PubnubApi.PubnubEventEngine.Subscribe.Invocations;
5+
6+
namespace PubnubApi.PubnubEventEngine.Subscribe.States {
7+
internal class ReceiveReconnectingState : Core.IState {
8+
9+
public IEnumerable<string> Channels;
10+
public IEnumerable<string> ChannelGroups;
11+
12+
public IEnumerable<IEffectInvocation> OnEntry { get; }
13+
public IEnumerable<IEffectInvocation> OnExit { get; }
14+
public Tuple<Core.IState, IEnumerable<IEffectInvocation>> Transition(IEvent e) {
15+
throw new NotImplementedException();
16+
}
17+
}
18+
}
19+
20+

0 commit comments

Comments
 (0)