File tree Expand file tree Collapse file tree 4 files changed +40
-14
lines changed Expand file tree Collapse file tree 4 files changed +40
-14
lines changed Original file line number Diff line number Diff line change @@ -81,10 +81,15 @@ export abstract class Connector {
8181 abstract presenceChannel ( channel : string ) : PresenceChannel ;
8282
8383 /**
84- * Leave the given channel.
84+ * Leave the given channel and its private & presence channels .
8585 */
8686 abstract leave ( channel : string ) : void ;
8787
88+ /**
89+ * Leave the given channel.
90+ */
91+ abstract leaveOne ( channel : string ) : void ;
92+
8893 /**
8994 * Get the socket_id of the connection.
9095 */
Original file line number Diff line number Diff line change @@ -48,12 +48,19 @@ export class NullConnector extends Connector {
4848 }
4949
5050 /**
51- * Leave the given channel.
51+ * Leave the given channel and its private & presence channels .
5252 */
5353 leave ( name : string ) : void {
5454 //
5555 }
5656
57+ /**
58+ * Leave the given channel.
59+ */
60+ leaveOne ( name : string ) : void {
61+ //
62+ }
63+
5764 /**
5865 * Get the socket ID for the connection.
5966 */
Original file line number Diff line number Diff line change @@ -81,20 +81,27 @@ export class PusherConnector extends Connector {
8181 }
8282
8383 /**
84- * Leave the given channel.
84+ * Leave the given channel and its private & presence channels .
8585 */
8686 leave ( name : string ) : void {
8787 let channels = [ name , 'private-' + name , 'presence-' + name ] ;
8888
8989 channels . forEach ( ( name : string , index : number ) => {
90- if ( this . channels [ name ] ) {
91- this . channels [ name ] . unsubscribe ( ) ;
92-
93- delete this . channels [ name ] ;
94- }
90+ this . leaveOne ( name ) ;
9591 } ) ;
9692 }
9793
94+ /**
95+ * Leave the given channel.
96+ */
97+ leaveOne ( name : string ) : void {
98+ if ( this . channels [ name ] ) {
99+ this . channels [ name ] . unsubscribe ( ) ;
100+
101+ delete this . channels [ name ] ;
102+ }
103+ }
104+
98105 /**
99106 * Get the socket ID for the connection.
100107 */
Original file line number Diff line number Diff line change @@ -94,20 +94,27 @@ export class SocketIoConnector extends Connector {
9494 }
9595
9696 /**
97- * Leave the given channel.
97+ * Leave the given channel and its private & presence channels .
9898 */
9999 leave ( name : string ) : void {
100100 let channels = [ name , 'private-' + name , 'presence-' + name ] ;
101101
102102 channels . forEach ( name => {
103- if ( this . channels [ name ] ) {
104- this . channels [ name ] . unsubscribe ( ) ;
105-
106- delete this . channels [ name ] ;
107- }
103+ this . leaveOne ( name ) ;
108104 } ) ;
109105 }
110106
107+ /**
108+ * Leave the given channel.
109+ */
110+ leaveOne ( name : string ) : void {
111+ if ( this . channels [ name ] ) {
112+ this . channels [ name ] . unsubscribe ( ) ;
113+
114+ delete this . channels [ name ] ;
115+ }
116+ }
117+
111118 /**
112119 * Get the socket ID for the connection.
113120 */
You can’t perform that action at this time.
0 commit comments