Open
Description
In list view, it shows 2 clients in the room.
Upon inspection, room is undefined and there are 0 clients.
State showing 0 items:
Console output showing 2 clients joined:
Client correctly gets room state:
React code:
import * as Colyseus from "colyseus.js";
function App() {
var client = new Colyseus.Client("ws://localhost:2567");
let room: Colyseus.Room;
const joinRoom = async () => {
room = await client.joinOrCreate("cg_chess");
console.log(room.state);
};
return (
<>
<div>
<button onClick={joinRoom}>
Join Room
</button>
</div>
</>
);
}
Server code:
export class CGChess extends Room<CGChessState> {
chess: Chess;
constructor() {
super();
this.chess = new Chess();
}
maxClients = 2;
onCreate (options: any) {
this.setState(new CGChessState());
}
onJoin (client: Client, options: any) {
this.state.players.set(client.sessionId, new Player());
if (this.state.players.size === 2) {
this.lock();
}
}
}
This might be related to #22 . I am using version 0.15.
"@colyseus/monitor": "^0.15.0",
"@colyseus/playground": "^0.15.3",
"@colyseus/tools": "^0.15.0",
"colyseus": "^0.15.0",
Other notes:
- On Playground, creating/joining room, setting up state, and onMessage() works properly.
- Same behavior occurs when only joining with 1 user.
Metadata
Metadata
Assignees
Labels
No labels