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.
```javascript fct_label="TypeScript" import { Room, FossilDeltaSerializer, serialize } from "colyseus";
@serialize(FossilDeltaSerializer) class MyRoom extends Room { // your room definition }
```javascript fct_label="JavaScript"
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
SchemaSerializerin 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.idhas been renamed toclient.Idroom.idhas been renamed toroom.Idroom.namehas been renamed toroom.Nameroom.sessionIdhas been renamed toroom.SessionIdroom.statehas been renamed toroom.Statee.messagehas been renamed toe.Message(onMessageEventArgsandErrorEventArgs)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
RoomUpdateEventArgshas been renamed toStateChangeEventArgs<T>TisIndexedDictionary<string, object>when using Fossil DeltaTisYourStateClasswhen using Schema.e.statehas been renamed toe.State