Last active
March 1, 2021 13:55
-
-
Save endel/ed1914c0d06df4d2b5b616f586f71188 to your computer and use it in GitHub Desktop.
Colyseus: using the same room handler for multiple rooms.
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
var Room = require('colyseus').Room | |
class ChatRoom extends Room { | |
constructor (options) { | |
super( options ) | |
this.name = options.name; | |
this.setState({ messages: [] }) | |
} | |
requestJoin(options) { | |
return this.name === options.name; | |
} | |
} |
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
client.join("chat_room", { name: "global" }); | |
client.join("chat_room", { name: "specific" }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment