Skip to content

Instantly share code, notes, and snippets.

@mobyjames
Created December 20, 2020 22:31
Show Gist options
  • Save mobyjames/90e140ae6e635ede7e48bcb56dc56b68 to your computer and use it in GitHub Desktop.
Save mobyjames/90e140ae6e635ede7e48bcb56dc56b68 to your computer and use it in GitHub Desktop.
const gameServer = new Server({
gracefullyShutdown: false,
});
registerGracefulShutdown(async (err) => {
console.log('shutting down...');
await broadcastAll('Sorry to interrupt. Servers are restarting shortly.');
await delay(10000);
await gameServer.gracefullyShutdown(true, err);
});
export async function broadcastAll(message: string) {
const roomListings = await matchMaker.query();
for (const listing of roomListings) {
await matchMaker.remoteRoomCall(listing.roomId, 'broadcast', ['alert', message]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment