Skip to content

Commit e7d588b

Browse files
committed
Try this
1 parent ed0079b commit e7d588b

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

session-draft.md

+19-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,23 @@ GameSessionState
1111
GameComplete
1212

1313

14+
```js
15+
class GameSessionModel {
16+
@Column
17+
server_url: string;
1418

15-
## RoomReady
16-
1) create game session
17-
2) populate players
18-
3)
19+
@PrimaryColumn
20+
match_id: number;
21+
}
22+
23+
class GameSessionPlayer {
24+
@ManyToOne(match_id)
25+
session: GameSessionModel;
26+
27+
connected: boolean;
28+
29+
abandoned: boolean;
30+
}
31+
32+
33+
```

src/app.service.ts

+16-7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { ReplayEntity } from 'gameserver/model/replay.entity';
1616
import { GameServerEntity } from 'gameserver/model/game-server.entity';
1717
import { PlayerNotLoadedEvent } from 'gateway/events/bans/player-not-loaded.event';
1818
import { AchievementCompleteEvent } from 'gateway/events/gs/achievement-complete.event';
19+
import { GameServerSessionEntity } from 'gameserver/model/game-server-session.entity';
1920

2021
@Injectable()
2122
export class AppService {
@@ -25,19 +26,27 @@ export class AppService {
2526
private readonly gameServerEntityRepository: Repository<GameServerEntity>,
2627
@InjectRepository(ReplayEntity)
2728
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,
2932
) {}
3033

31-
32-
@Cron('*/30 * * * * *')
34+
@Cron("*/30 * * * * *")
3335
async actualizeServers() {
3436
// for all servers
3537
const all = await this.gameServerEntityRepository.find();
3638

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+
3747
await Promise.all(
38-
all.map(async gs => {
48+
all2.map(async (gs) => {
3949
await this.ebus.publish(new ServerActualizationRequestedEvent(gs.url));
40-
await new Promise(r => setTimeout(r, 1000)) // spread them a little
4150
}),
4251
);
4352
}
@@ -57,11 +66,11 @@ export class AppService {
5766
KillServerRequestedEvent,
5867
BanSystemEvent,
5968
PlayerNotLoadedEvent,
60-
AchievementCompleteEvent
69+
AchievementCompleteEvent,
6170
];
6271

6372
this.ebus
6473
.pipe(ofType(...publicEvents))
65-
.subscribe(t => this.redisEventQueue.emit(t.constructor.name, t));
74+
.subscribe((t) => this.redisEventQueue.emit(t.constructor.name, t));
6675
}
6776
}

0 commit comments

Comments
 (0)