@@ -188,7 +188,7 @@ const connectWS = (port: string): Promise<WebSocket> =>
188188 ws . onerror = ( ) => reject ( new Error ( `WS connection failed on ${ port } ` ) ) ;
189189 } ) ;
190190
191- const waitForDDP = ( ws : WebSocket , id : string | 'handshake' , sendAction : ( ) => void ) : Promise < any > => {
191+ const waitForDDP = ( ws : WebSocket , id : string | 'handshake' , stringifiedJsonPayload : string ) : Promise < any > => {
192192 return new Promise ( ( resolve , reject ) => {
193193 const timeout = setTimeout ( ( ) => {
194194 cleanup ( ) ;
@@ -237,25 +237,25 @@ const waitForDDP = (ws: WebSocket, id: string | 'handshake', sendAction: () => v
237237 ws . addEventListener ( 'close' , onClose ) ;
238238 ws . addEventListener ( 'error' , onError ) ;
239239
240- sendAction ( ) ;
240+ ws . send ( stringifiedJsonPayload ) ;
241241 } ) ;
242242} ;
243243
244244export const ddpLogin = async ( resume : string ) : Promise < WebSocket > => {
245245 const ws = await connectWS ( process . env . DDP_LOGIN_PORT || '3000' ) ;
246246 const loginId = `login-${ Date . now ( ) } ` ;
247247
248- await waitForDDP ( ws , 'handshake' , ( ) => ws . send ( JSON . stringify ( { msg : 'connect' , version : '1' , support : [ '1' ] } ) ) ) ;
248+ await waitForDDP ( ws , 'handshake' , JSON . stringify ( { msg : 'connect' , version : '1' , support : [ '1' ] } ) ) ;
249249
250- await waitForDDP ( ws , loginId , ( ) => ws . send ( JSON . stringify ( { msg : 'method' , id : loginId , method : 'login' , params : [ { resume } ] } ) ) ) ;
250+ await waitForDDP ( ws , loginId , JSON . stringify ( { msg : 'method' , id : loginId , method : 'login' , params : [ { resume } ] } ) ) ;
251251
252252 return ws ;
253253} ;
254254
255255export const setUserAwayWS = async ( ws : WebSocket ) : Promise < void > => {
256256 const id = `away-${ Date . now ( ) } ` ;
257257
258- await waitForDDP ( ws , id , ( ) => ws . send ( JSON . stringify ( { msg : 'method' , method : 'UserPresence:away' , params : [ ] , id } ) ) ) ;
258+ await waitForDDP ( ws , id , JSON . stringify ( { msg : 'method' , method : 'UserPresence:away' , params : [ ] , id } ) ) ;
259259} ;
260260
261261export const setUserOnline = ( overrideCredentials = credentials , config ?: IRequestConfig ) => {
0 commit comments