Skip to content

Commit 9854eab

Browse files
committed
feat: added shutdown method
1 parent a418251 commit 9854eab

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

templates/base/server/.hathora/store.ts.hbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ setInterval(() => {
6565
pendingMessages.clear();
6666
}, {{#if tick}}{{tick}}{{else}}50{{/if}});
6767
setInterval(() => {
68-
rooms.forEach(({ subscriptions }, stateId) => {
68+
rooms.forEach(async ({ impl, subscriptions }, stateId) => {
6969
if (subscriptions.size === 0) {
70+
await impl.onShutdown(ctxNoEvents(chance, time, stateId));
7071
rooms.delete(stateId);
7172
log.unload(stateId);
7273
}

templates/bootstrap/server/impl.ts.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class Impl implements Methods<InternalState> {
3737
{{#if tick}}
3838
onTick(state: InternalState, ctx: Context, timeDelta: number): void {}
3939
{{/if}}
40+
onShutdown(state: InternalState, ctx: Context): void {}
4041
}
4142
{{#*inline "renderDefault"}}
4243
{{#if (eq type "array")}}

0 commit comments

Comments
 (0)