Skip to content

Ability to serialize/deserialize Schema on the server side #115

Open
@jrabek

Description

@jrabek

Thanks again @endel for the great multiplayer game framework! If you would provide some basic guidance on this enhancement I would be happy to implement it in a PR.

Summary

This is a request for a Schema method for completely serializing/deserializing the server Schema (i.e. game state) so that it can be persisted in a database.

Motivation

In the current colyseus server architecture, the game state (i.e. some Schema derived class) persists in memory in one specific server.

One of the shortcomings is that it prevents seamless deploys and crash recovery since the game state is in memory and therefore lost when the server process is killed. For certain game types (e.g. long running games, games involving money) it is critical that game state is not lost.

To support a more robust game state, the ability to fully serialize the server Schema in a way that it could be stored in a database is needed.

Currently there are two ways to serialize the server Schema neither of which are meant for deserializing it later.

  1. toJSON: This method is meant for logging / debugging
  2. encodeAll / decode: These are meant to send state updates to the clients and not for recreating the entire server Schema.

For (2) this is what happens when the server state is serialized/deserialized using encodeAll / decode: https://gist.github.com/jrabek/6303d3f94b82c692de7721f0fc331f8c.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions