Created
December 20, 2020 22:31
-
-
Save mobyjames/90e140ae6e635ede7e48bcb56dc56b68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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