Migrating to version 0.10 (from 0.9)¶
Server-side¶
EntityMap<T>
has been removed. If you're using EntityMap<T>
to describe a map of entities, you should use the plain TypeScript alternative now. e.g. Replace "EntityMap<Player>
" with "{[id: string]: Player}
", or migrate to the new serializer.
New default serializer¶
Colyseus 0.10 has introduced a new serialization method (SchemaSerializer
). Even though it's recommened to use the new serializer, you can continue using the previous one (FossilDeltaSerializer
).
I want to continue using the previous serializer¶
No problem, check below how to continue using the previous serializer using TypeScript or plain JavaScript.
import { Room, FossilDeltaSerializer, serialize } from "colyseus";
@serialize(FossilDeltaSerializer)
class MyRoom extends Room {
// your room definition
}
const colyseus = require('colyseus');
class MyRoom extends colyseus.Room {
// your room definition
}
colyseus.serialize(colyseus.FossilDeltaSerializer)(MyRoom);
I want to migrate to the new serializer¶
Great, hopefully you won't have to make many changes in your project. In the client-side, the way to listen for state patches has changed slightly.
- See how to use the new
SchemaSerializer
in the server-side. - See how to listen for changes in the state using
SchemaSerializer
.
Client-side¶
colyseus-unity3d¶
It's highly recommended to migrate to the new schema serializer. See how to generate the schema in the client-side based on the definitions from the server.
client.id
has been renamed toclient.Id
room.id
has been renamed toroom.Id
room.name
has been renamed toroom.Name
room.sessionId
has been renamed toroom.SessionId
room.state
has been renamed toroom.State
e.message
has been renamed toe.Message
(onMessageEventArgs
andErrorEventArgs
)Room<T>
needs to provide the generic type for state holder- when using Fossil Delta, it's
Room<IndexedDictionary<string, object>>
- when using Schema it's
Room<YourStateClass>
- when using Fossil Delta, it's
RoomUpdateEventArgs
has been renamed toStateChangeEventArgs<T>
T
isIndexedDictionary<string, object>
when using Fossil DeltaT
isYourStateClass
when using Schema.e.state
has been renamed toe.State