Joining to specific room
-
SERVER SIDE
export class Table extends Room { onInit (options: any) { } requestJoin (options: any, isNew: boolean) { return (options.create) ? (options.create && isNew) : this.clients.length > 0; } onJoin (client: Client, options: any) {} onMessage (client: Client, message: any) {} onLeave (client: Client, consented: boolean) {} onDispose() {} }
CLIENT SIDE
import * as Colyseus from "colyseus.js"; let client = new Colyseus.Client("ws://localhost:2567"); let room1 = client.join("table", {create: true}); room1.onJoin.add(() => { console.log(client.id, "created", room1.name, " ", room1.id); }); let room2 = client.join("table", {create: true}); room2.onJoin.add(() => { console.log(client.id, "created", room2.name, " ", room2.id); });
This will create 2 different rooms. How can I specify e client to join to e specific room?
-
Hi,
Will it do that if you leave the options out? I.e.:
import * as Colyseus from "colyseus.js";
let client = new Colyseus.Client("ws://localhost:2567");let room1 = client.join("table");
room1.onJoin.add(() => {
console.log(client.id, "created", room1.name, " ", room1.id);
});let room2 = client.join("table");
room2.onJoin.add(() => {
console.log(client.id, "created", room2.name, " ", room2.id);
});