@@ -16,6 +16,7 @@ import { ReplayEntity } from 'gameserver/model/replay.entity';
16
16
import { GameServerEntity } from 'gameserver/model/game-server.entity' ;
17
17
import { PlayerNotLoadedEvent } from 'gateway/events/bans/player-not-loaded.event' ;
18
18
import { AchievementCompleteEvent } from 'gateway/events/gs/achievement-complete.event' ;
19
+ import { GameServerSessionEntity } from 'gameserver/model/game-server-session.entity' ;
19
20
20
21
@Injectable ( )
21
22
export class AppService {
@@ -25,19 +26,27 @@ export class AppService {
25
26
private readonly gameServerEntityRepository : Repository < GameServerEntity > ,
26
27
@InjectRepository ( ReplayEntity )
27
28
private readonly replayEntityRepository : Repository < ReplayEntity > ,
28
- @Inject ( 'QueryCore' ) private readonly redisEventQueue : ClientProxy ,
29
+ @InjectRepository ( GameServerSessionEntity )
30
+ private readonly gameServerSessionEntityRepository : Repository < GameServerSessionEntity > ,
31
+ @Inject ( "QueryCore" ) private readonly redisEventQueue : ClientProxy ,
29
32
) { }
30
33
31
-
32
- @Cron ( '*/30 * * * * *' )
34
+ @Cron ( "*/30 * * * * *" )
33
35
async actualizeServers ( ) {
34
36
// for all servers
35
37
const all = await this . gameServerEntityRepository . find ( ) ;
36
38
39
+ const all2 = await this . gameServerSessionEntityRepository . find ( ) ;
40
+
41
+ await Promise . all (
42
+ all . map ( async ( gs ) => {
43
+ await this . ebus . publish ( new ServerActualizationRequestedEvent ( gs . url ) ) ;
44
+ } ) ,
45
+ ) ;
46
+
37
47
await Promise . all (
38
- all . map ( async gs => {
48
+ all2 . map ( async ( gs ) => {
39
49
await this . ebus . publish ( new ServerActualizationRequestedEvent ( gs . url ) ) ;
40
- await new Promise ( r => setTimeout ( r , 1000 ) ) // spread them a little
41
50
} ) ,
42
51
) ;
43
52
}
@@ -57,11 +66,11 @@ export class AppService {
57
66
KillServerRequestedEvent ,
58
67
BanSystemEvent ,
59
68
PlayerNotLoadedEvent ,
60
- AchievementCompleteEvent
69
+ AchievementCompleteEvent ,
61
70
] ;
62
71
63
72
this . ebus
64
73
. pipe ( ofType ( ...publicEvents ) )
65
- . subscribe ( t => this . redisEventQueue . emit ( t . constructor . name , t ) ) ;
74
+ . subscribe ( ( t ) => this . redisEventQueue . emit ( t . constructor . name , t ) ) ;
66
75
}
67
76
}
0 commit comments