-
Notifications
You must be signed in to change notification settings - Fork 126
/
Copy pathHandshakeFailedState.cs
60 lines (56 loc) · 1.87 KB
/
HandshakeFailedState.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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) {
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.ReconnectEvent reconnect:
return new Tuple<Core.IState, IEnumerable<IEffectInvocation>>(
new HandshakingState() {
Channels = reconnect.Channels,
ChannelGroups = reconnect.ChannelGroups,
},
new[] {
new HandshakeInvocation() {
Channels = reconnect.Channels,
ChannelGroups = reconnect.ChannelGroups,
},
}
);
case Events.SubscriptionRestoredEvent subscriptionRestored:
return new Tuple<IState, IEnumerable<IEffectInvocation>>(
new ReceivingState() {
Channels = subscriptionRestored.Channels,
ChannelGroups = subscriptionRestored.ChannelGroups
},
new[] {
new ReceiveMessagesInvocation() {
Channels = subscriptionRestored.Channels,
ChannelGroups = subscriptionRestored.ChannelGroups,
},
}
);
default: return null;
}
}
}
}