const DEFAULT_GAME_ROOM = "star_gazer_lab"; class NetClient { connect(url) { this.client = new Colyseus.Client('ws://localhost:2567'); } joinGame() { this.client.joinOrCreate(DEFAULT_GAME_ROOM).then(this.onConnect.bind(this)).catch( this.onError.bind(this)); } onConnect(room) { console.log(room.sessionId, "joined", room.name); room.onStateChange(this.onUpdate); room.onMessage(this.onMessage); room.onError(this.onError); room.onLeave(this.onLeave); } onUpdate(state) { console.log("received new state from server"); console.log(state); } onMessage(message) { console.log("Received new message from server") } onError(error) { console.log(error); } onLeave() { console.log("Client left room") } } export default NetClient;