File tree 6 files changed +49
-1
lines changed
PubnubApi/EventEngine/Subscribe 6 files changed +49
-1
lines changed Original file line number Diff line number Diff line change
1
+ using System . Collections . Generic ;
2
+ using System . Linq ;
3
+ using System . Threading . Tasks ;
4
+ using Newtonsoft . Json ;
5
+ using PubnubApi . EndPoint ;
6
+ using PubnubApi . PubnubEventEngine . Core ;
7
+ using PubnubApi . PubnubEventEngine . Subscribe . Invocations ;
8
+
9
+ namespace PubnubApi . PubnubEventEngine . Subscribe . Effects {
10
+ internal class LeaveEffectHandler : Core . IEffectHandler < LeaveInvocation > {
11
+ private SubscribeManager2 manager ;
12
+ private EventQueue eventQueue ;
13
+
14
+ public LeaveEffectHandler ( SubscribeManager2 manager , EventQueue eventQueue ) {
15
+ this . manager = manager ;
16
+ this . eventQueue = eventQueue ;
17
+ }
18
+
19
+ public async Task Run ( LeaveInvocation invocation ) {
20
+ // TODO identity method for unsubscribe all
21
+ //var resp = null;//await manager.UnsubscribeRequest<string>(
22
+ // PNOperationType.PNSubscribeOperation,
23
+ // invocation.Channels.ToArray(),
24
+ // invocation.ChannelGroups.ToArray(),
25
+ //);
26
+
27
+
28
+ }
29
+
30
+ public async Task Cancel ( ) {
31
+ //manager.LeaveRequestCancellation();
32
+ }
33
+ }
34
+ }
Original file line number Diff line number Diff line change @@ -66,4 +66,11 @@ internal class ReceiveReconnectInvocation: Core.IEffectInvocation
66
66
}
67
67
68
68
internal class CancelReceiveReconnectInvocation : ReceiveReconnectInvocation , Core . IEffectCancelInvocation { }
69
+
70
+ internal class LeaveInvocation : Core . IEffectInvocation
71
+ {
72
+ public IEnumerable < string > Channels ;
73
+ public IEnumerable < string > ChannelGroups ;
74
+ }
75
+ internal class CancelLeaveInvocation : LeaveInvocation , Core . IEffectCancelInvocation { }
69
76
}
Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ internal class UnsubscribedState : Core.State
9
9
{
10
10
public IEnumerable < string > Channels ;
11
11
public IEnumerable < string > ChannelGroups ;
12
- public override IEnumerable < IEffectInvocation > OnEntry { get ; } = null ;
12
+ public override IEnumerable < IEffectInvocation > OnEntry => new LeaveInvocation ( )
13
+ { Channels = this . Channels , ChannelGroups = this . ChannelGroups } . AsArray ( ) ;
13
14
public override IEnumerable < IEffectInvocation > OnExit { get ; } = null ;
14
15
15
16
public override TransitionResult Transition ( Core . IEvent e )
Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ public SubscribeEventEngine(SubscribeManager2 subscribeManager) {
15
15
dispatcher . Register < Invocations . HandshakeInvocation , Effects . HandshakeEffectHandler > ( handshakeHandler ) ;
16
16
dispatcher . Register < Invocations . CancelHandshakeInvocation , Effects . HandshakeEffectHandler > ( handshakeHandler ) ;
17
17
18
+ var leaveHandler = new Effects . LeaveEffectHandler ( subscribeManager , eventQueue ) ;
19
+ dispatcher . Register < Invocations . LeaveInvocation , Effects . LeaveEffectHandler > ( leaveHandler ) ;
20
+ dispatcher . Register < Invocations . CancelLeaveInvocation , Effects . LeaveEffectHandler > ( leaveHandler ) ;
21
+
18
22
currentState = new UnsubscribedState ( ) ;
19
23
}
20
24
}
Original file line number Diff line number Diff line change 229
229
<Compile Include =" ..\PubnubApi\EventEngine\ReceivingEffectHandler.cs" Link =" EventEngine\ReceivingEffectHandler.cs" />
230
230
<Compile Include =" ..\PubnubApi\EventEngine\State.cs" Link =" EventEngine\State.cs" />
231
231
<Compile Include =" ..\PubnubApi\EventEngine\Subscribe\Effects\HandshakeEffectHandler.cs" Link =" EventEngine\Subscribe\Effects\HandshakeEffectHandler.cs" />
232
+ <Compile Include =" ..\PubnubApi\EventEngine\Subscribe\Effects\LeaveEffectHandler.cs" Link =" EventEngine\Subscribe\Effects\LeaveEffectHandler.cs" />
232
233
<Compile Include =" ..\PubnubApi\EventEngine\Subscribe\Events\SubscriptionEvents.cs" Link =" EventEngine\Subscribe\Events\SubscriptionEvents.cs" />
233
234
<Compile Include =" ..\PubnubApi\EventEngine\Subscribe\Invocations\SubscriptionInvocations.cs" Link =" EventEngine\Subscribe\Invocations\SubscriptionInvocations.cs" />
234
235
<Compile Include =" ..\PubnubApi\EventEngine\Subscribe\States\HandshakeFailedState.cs" Link =" EventEngine\Subscribe\States\HandshakeFailedState.cs" />
Original file line number Diff line number Diff line change 346
346
<Compile Include =" ..\PubnubApi\EventEngine\ReceivingEffectHandler.cs" Link =" EventEngine\ReceivingEffectHandler.cs" />
347
347
<Compile Include =" ..\PubnubApi\EventEngine\State.cs" Link =" EventEngine\State.cs" />
348
348
<Compile Include =" ..\PubnubApi\EventEngine\Subscribe\Effects\HandshakeEffectHandler.cs" Link =" EventEngine\Subscribe\Effects\HandshakeEffectHandler.cs" />
349
+ <Compile Include =" ..\PubnubApi\EventEngine\Subscribe\Effects\LeaveEffectHandler.cs" Link =" EventEngine\Subscribe\Effects\LeaveEffectHandler.cs" />
349
350
<Compile Include =" ..\PubnubApi\EventEngine\Subscribe\Events\SubscriptionEvents.cs" Link =" EventEngine\Subscribe\Events\SubscriptionEvents.cs" />
350
351
<Compile Include =" ..\PubnubApi\EventEngine\Subscribe\Invocations\SubscriptionInvocations.cs" Link =" EventEngine\Subscribe\Invocations\SubscriptionInvocations.cs" />
351
352
<Compile Include =" ..\PubnubApi\EventEngine\Subscribe\States\HandshakeFailedState.cs" Link =" EventEngine\Subscribe\States\HandshakeFailedState.cs" />
You can’t perform that action at this time.
0 commit comments