Migrating to version 0.9 (from 0.6.x or 0.8.x)¶
Server-side¶
ClusterServer
has been deprecated. UseServer
instead.Room#verifyClient(client, options)
has been renamed toRoom#onAuth(options)
- Integration with
uws
module has changed. See how to integrate here.
Client-side¶
colyseus.js¶
room.onData
has been renamed toroom.onMessage
.room.onUpdate
has been renamed toroom.onStateChange
room.data
has been renamed toroom.state
colyseus-unity3d¶
room.OnData
has been renamed toroom.OnMessage
.room.OnUpdate
has been renamed toroom.OnStateChange
room.data
has been renamed toroom.state
Migrating to 0.5 (from 0.4.x)¶
Use Server#listen
to bind http port.¶
The Server
is now using the ClusterServer
under the hood, which will spawn
workers automatically. If you're using the Server
instead of ClusterServer
directly, you should call its listen
method.
OLD
import { createServer } from 'http';
import { Server } from 'colyseus';
const httpServer = createServer(app);
const gameServer = new Server({ server: httpServer });
httpServer.listen(2567);
NEW
import { createServer } from 'http';
import { Server } from 'colyseus';
const httpServer = createServer(app);
const gameServer = new Server({ server: httpServer });
gameServer.listen(2567); // calling 'listen' from gameServer instead of httpServer
constructor
signature changed. use onCreate
instead.¶
OLD
NEW
constructor () {
// room has been constructed. no options available yet!
}
onCreate (options) {
// ... initialize the room
}
requestJoin
- can return type can be either boolean
or number
(0..1
)¶
OLD
requestJoin (options) {
// accept connections if this room is not full.
return this.clients.length < 10;
}
NEW
requestJoin (options) {
// give priority to connect on rooms with fewer clients.
return 1 - (this.clients.length) / 10;
}
use patchRate
property instead of setPatchRate()
method.¶
OLD
NEW
client.id
/ client.sessionId
¶
client.sessionId
- is a unique identifier of a user connected in a room.client.id
- is a unique identifier of a user. if the user connects to the same room twice, you can identify he has two sessions by checking forclient.id
. If you don't bother having the same user connected multiple times in a room, always useclient.sessionId
to identify it.
new room.maxClients
property.¶
OLD - if you're just checking for client.length
on requestJoin
, you probably can switch to maxClients
instead.
NEW
Migrating to 0.4 (from 0.3.x)¶
constructor / patch-rate¶
OLD constructor / patch-rate
NEW constructor / patch-rate