@@ -224,14 +224,8 @@ export class FcmListenerManager {
224
224
const androidId = credentials . gcm . androidId ;
225
225
const securityToken = credentials . gcm . securityToken ;
226
226
this . listeners [ steamId ] = new PushReceiverClient ( androidId , securityToken , [ ] ) ;
227
- // TODO! Something is messed up here. I tested with two steam accounts with credentials on the same discord
228
- // guild. For some reason the two fcm instances wont work together properly. When I pair in-game with account
229
- // 1, the above steamId is the one for account 2, but the data below is correct and from account 1. For the
230
- // love of god I cant figure out how to solve it. When I print each fcm listener (this.listeners) I can see
231
- // that each listener have the correct androidId and securityToken for the given steamId. This needs to be
232
- // solved before v2 release.
233
227
this . listeners [ steamId ] . on ( 'ON_DATA_RECEIVED' , ( data : unknown ) => {
234
- const funcName = `[FcmListenerManager: ON_DATA_RECEIVED: ${ steamId } ]` ;
228
+ const funcName = `[FcmListenerManager: ON_DATA_RECEIVED]` ;
235
229
if ( ! isValidFcmNotificaton ( data ) ) {
236
230
log . warn ( `${ funcName } data is not of type FcmNotification. Data: ${ JSON . stringify ( data ) } ` ) ;
237
231
return ;
@@ -242,7 +236,7 @@ export class FcmListenerManager {
242
236
return ;
243
237
}
244
238
245
- this . onDataReceived ( steamId , data ) ;
239
+ this . onDataReceived ( data ) ;
246
240
} ) ;
247
241
this . listeners [ steamId ] . connect ( ) ;
248
242
log . info ( `${ funcName } FCM Listener started.` ) ;
@@ -259,8 +253,8 @@ export class FcmListenerManager {
259
253
}
260
254
}
261
255
262
- private onDataReceived ( steamId : types . SteamId , data : FcmNotification ) : void {
263
- const funcName = `[FcmListenerManager: onDataReceived: ${ steamId } ]` ;
256
+ private onDataReceived ( data : FcmNotification ) : void {
257
+ const funcName = `[FcmListenerManager: onDataReceived]` ;
264
258
const appData : AppDataItem [ ] = data . appData ;
265
259
266
260
const title = appData . find ( item => item . key === 'title' ) ?. value ;
@@ -290,9 +284,11 @@ export class FcmListenerManager {
290
284
291
285
switch ( channelId ) {
292
286
case ChannelIds . PAIRING : {
287
+ const steamId = ( body as PairingServerBody || body as PairingEntityBody ) . playerId ;
288
+ const funcNamePairing = `[FcmListenerManager: onDataReceived: ${ steamId } ]` ;
293
289
switch ( body . type ) {
294
290
case PairingTypes . SERVER : {
295
- log . info ( `${ funcName } ${ ChannelIds . PAIRING } : ${ PairingTypes . SERVER } ` ) ;
291
+ log . info ( `${ funcNamePairing } ${ ChannelIds . PAIRING } : ${ PairingTypes . SERVER } ` ) ;
296
292
if ( ! isValidPairingServerBody ( body ) ) return ;
297
293
298
294
pairingServer ( this , steamId , body ) ;
@@ -303,31 +299,31 @@ export class FcmListenerManager {
303
299
// entity pairing body
304
300
switch ( body . entityType ) {
305
301
case PairingEntityTypes . SMART_SWITCH : {
306
- log . info ( `${ funcName } ${ ChannelIds . PAIRING } : ${ PairingTypes . ENTITY } : ` +
302
+ log . info ( `${ funcNamePairing } ${ ChannelIds . PAIRING } : ${ PairingTypes . ENTITY } : ` +
307
303
`${ PairingEntityNames . SMART_SWITCH } ` ) ;
308
304
if ( ! isValidPairingEntityBody ( body ) ) return ;
309
305
310
306
pairingEntitySmartSwitch ( this , steamId , body ) ;
311
307
} break ;
312
308
313
309
case PairingEntityTypes . SMART_ALARM : {
314
- log . info ( `${ funcName } ${ ChannelIds . PAIRING } : ${ PairingTypes . ENTITY } : ` +
310
+ log . info ( `${ funcNamePairing } ${ ChannelIds . PAIRING } : ${ PairingTypes . ENTITY } : ` +
315
311
`${ PairingEntityNames . SMART_ALARM } ` ) ;
316
312
if ( ! isValidPairingEntityBody ( body ) ) return ;
317
313
318
314
pairingEntitySmartAlarm ( this , steamId , body ) ;
319
315
} break ;
320
316
321
317
case PairingEntityTypes . STORAGE_MONITOR : {
322
- log . info ( `${ funcName } ${ ChannelIds . PAIRING } : ${ PairingTypes . ENTITY } : ` +
318
+ log . info ( `${ funcNamePairing } ${ ChannelIds . PAIRING } : ${ PairingTypes . ENTITY } : ` +
323
319
`${ PairingEntityNames . STORAGE_MONITOR } ` ) ;
324
320
if ( ! isValidPairingEntityBody ( body ) ) return ;
325
321
326
322
pairingEntityStorageMonitor ( this , steamId , body ) ;
327
323
} break ;
328
324
329
325
default : {
330
- log . info ( `${ funcName } ${ ChannelIds . PAIRING } : ${ PairingTypes . ENTITY } : other.` ) ;
326
+ log . info ( `${ funcNamePairing } ${ ChannelIds . PAIRING } : ${ PairingTypes . ENTITY } : other.` ) ;
331
327
if ( ! isValidPairingEntityBody ( body ) ) return ;
332
328
} break ;
333
329
}
@@ -346,7 +342,7 @@ export class FcmListenerManager {
346
342
log . info ( `${ funcName } ${ ChannelIds . ALARM } : ${ AlarmTypes . ALARM } ` ) ;
347
343
if ( ! isValidAlarmAlarmBody ( body ) ) return ;
348
344
349
- alarmAlarm ( this , steamId , title , message , body ) ;
345
+ // alarmAlarm(this, steamId, title, message, body);
350
346
} break ;
351
347
352
348
default : {
@@ -355,7 +351,7 @@ export class FcmListenerManager {
355
351
log . info ( `${ funcName } ${ ChannelIds . ALARM } : plugin` ) ;
356
352
if ( ! isValidAlarmPluginBody ( body ) ) return ;
357
353
358
- alarmPlugin ( this , steamId , title , message , body ) ;
354
+ // alarmPlugin(this, steamId, title, message, body);
359
355
break ;
360
356
}
361
357
@@ -371,7 +367,7 @@ export class FcmListenerManager {
371
367
log . info ( `${ funcName } ${ ChannelIds . PLAYER } : ${ PlayerTypes . DEATH } ` ) ;
372
368
if ( ! isValidPlayerDeathBody ( body ) ) return ;
373
369
374
- playerDeath ( this , steamId , title , body ) ;
370
+ // playerDeath(this, steamId, title, body);
375
371
} break ;
376
372
377
373
default : {
@@ -387,7 +383,7 @@ export class FcmListenerManager {
387
383
log . info ( `${ funcName } ${ ChannelIds . TEAM } : ${ TeamTypes . LOGIN } ` ) ;
388
384
if ( ! isValidTeamLoginBody ( body ) ) return ;
389
385
390
- teamLogin ( this , steamId , body ) ;
386
+ // teamLogin(this, steamId, body);
391
387
} break ;
392
388
393
389
default : {
@@ -403,7 +399,7 @@ export class FcmListenerManager {
403
399
log . info ( `${ funcName } ${ ChannelIds . NEWS } : ${ NewsTypes . NEWS } ` ) ;
404
400
if ( ! isValidNewsNewsBody ( body ) ) return ;
405
401
406
- newsNews ( this , steamId , title , message , body ) ;
402
+ // newsNews(this, steamId, title, message, body);
407
403
} break ;
408
404
409
405
default : {
0 commit comments