colyseus.js for the browser
JavaScript/TypeScript client for
Colyseus - a Minimalist Multiplayer
Game Server for Node.js.
Usage
import * as Colyseus from "colyseus.js";
var client = new Colyseus.Client('ws://localhost:2657');
var roomName = "room_name"
var room = client.join(roomName)
room.onJoin.add(function() {
console.log(client.id, "joined", roomName)
})
room.onUpdate.add(function(patches) {
console.log(roomName, "patches comming:", patches)
})
room.onPatch.add(function(patches) {
console.log(roomName, "will apply these changes:", patches)
})
room.onData.add(function(data) {
console.log(client.id, "received on", roomName, data)
})
room.onError.add(function() {
console.log(client.id, "couldn't join", roomName)
})
room.onLeave.add(function() {
console.log(client.id, "left", roomName)
})
License
MIT