@@ -54,14 +54,24 @@ class RealtimePresence extends EventEmitter {
5454 this . pendingPresence = [ ] ;
5555 }
5656
57- async enter ( data : unknown ) : Promise < void > {
57+ enter ( ...args : any [ ] ) : Promise < void > {
58+ Utils . detectV1Callback ( args , 0 ) ;
59+ return this . _enterImpl ( args [ 0 ] ) ;
60+ }
61+
62+ private async _enterImpl ( data : unknown ) : Promise < void > {
5863 if ( isAnonymousOrWildcard ( this ) ) {
5964 throw new ErrorInfo ( 'clientId must be specified to enter a presence channel' , 40012 , 400 ) ;
6065 }
6166 return this . _enterOrUpdateClient ( undefined , undefined , data , 'enter' ) ;
6267 }
6368
64- async update ( data : unknown ) : Promise < void > {
69+ update ( ...args : any [ ] ) : Promise < void > {
70+ Utils . detectV1Callback ( args , 0 ) ;
71+ return this . _updateImpl ( args [ 0 ] ) ;
72+ }
73+
74+ private async _updateImpl ( data : unknown ) : Promise < void > {
6575 if ( isAnonymousOrWildcard ( this ) ) {
6676 throw new ErrorInfo ( 'clientId must be specified to update presence data' , 40012 , 400 ) ;
6777 }
@@ -129,7 +139,12 @@ class RealtimePresence extends EventEmitter {
129139 }
130140 }
131141
132- async leave ( data : unknown ) : Promise < void > {
142+ leave ( ...args : any [ ] ) : Promise < void > {
143+ Utils . detectV1Callback ( args , 0 ) ;
144+ return this . _leaveImpl ( args [ 0 ] ) ;
145+ }
146+
147+ private async _leaveImpl ( data : unknown ) : Promise < void > {
133148 if ( isAnonymousOrWildcard ( this ) ) {
134149 throw new ErrorInfo ( 'clientId must have been specified to enter or leave a presence channel' , 40012 , 400 ) ;
135150 }
@@ -176,7 +191,12 @@ class RealtimePresence extends EventEmitter {
176191 }
177192 }
178193
179- async get ( params ?: RealtimePresenceParams ) : Promise < PresenceMessage [ ] > {
194+ get ( ...args : any [ ] ) : Promise < PresenceMessage [ ] > {
195+ Utils . detectV1Callback ( args , 0 ) ;
196+ return this . _getImpl ( args [ 0 ] ) ;
197+ }
198+
199+ private async _getImpl ( params ?: RealtimePresenceParams ) : Promise < PresenceMessage [ ] > {
180200 const waitForSync = ! params || ( 'waitForSync' in params ? params . waitForSync : true ) ;
181201
182202 function toMessages ( members : PresenceMap ) : PresenceMessage [ ] {
@@ -204,7 +224,12 @@ class RealtimePresence extends EventEmitter {
204224 return toMessages ( this . members ) ;
205225 }
206226
207- async history ( params : RealtimeHistoryParams | null ) : Promise < PaginatedResult < PresenceMessage > > {
227+ history ( ...args : any [ ] ) : Promise < PaginatedResult < PresenceMessage > > {
228+ Utils . detectV1Callback ( args , 0 ) ;
229+ return this . _historyImpl ( args [ 0 ] ) ;
230+ }
231+
232+ private async _historyImpl ( params : RealtimeHistoryParams | null ) : Promise < PaginatedResult < PresenceMessage > > {
208233 Logger . logAction ( this . logger , Logger . LOG_MICRO , 'RealtimePresence.history()' , 'channel = ' + this . name ) ;
209234 // We fetch this first so that any plugin-not-provided error takes priority over other errors
210235 const restMixin = this . channel . client . rest . presenceMixin ;
@@ -407,7 +432,12 @@ class RealtimePresence extends EventEmitter {
407432 } ) ;
408433 }
409434
410- async subscribe ( ..._args : unknown [ ] /* [event], listener */ ) : Promise < void > {
435+ subscribe ( ..._args : unknown [ ] /* [event], listener */ ) : Promise < void > {
436+ Utils . detectV1Callback ( _args , 2 ) ;
437+ return this . _subscribeImpl ( _args ) ;
438+ }
439+
440+ private async _subscribeImpl ( _args : unknown [ ] ) : Promise < void > {
411441 const args = RealtimeChannel . processListenerArgs ( _args ) ;
412442 const event = args [ 0 ] ;
413443 const listener = args [ 1 ] ;
0 commit comments