Colyseus Versions Save

⚔ Multiplayer Framework for Node.js

0.14.0

3 years ago

Check out the migration guide from 0.13 to 0.14 here.

The @colyseus/schema has received a major restructuring internally, here's what has changed at a glance:

  • Instance-sharing is now supported! You may use the same reference of a schema instance multiple times for synchronization without having to .clone() it.
  • Better @filter() implementation, and the addition of @filterChildren(). Although filters are still not recommended for fast-paced games, it should serve turn-based scenarios pretty well!
  • The MapSchema now uses a real Map underneath instead of plain objects.
  • It is not recommended to implement constructor() inside your schemas. Use .assign({ ... }) instead.

Besides the schema changes, here are some small changes in the framework itself:

  • simulateLatency(): this utility has been included to help you simulate networking delays during development.
  • broadcastPatch(): this internal method has been exposed, so if you wanna have control over when to send state patches to connected clients, now you can!
  • Bugfix: messages from "disconnecting" clients are now being dropped. (During some disconnection scenarios, the "client" instance of a particular "sessionId" was already removed from the server, but messages from that "sessionId" were still arriving at the server.)

The website was re-branded to focus on the maintenance and development of the framework, as well as giving more exposure to the Discord community!

Thank you all for the support! ❤

0.13.0

4 years ago

See how to migrate from 0.12 to 0.13

Breaking changes

  • onMessage now has a required "type" argument. (#315)
  • Matchmaking errors now are exposed with code and message in the client-side (317)

Reworked how to send and receive messages:

On previous versions, there was no concept of a "message type". All messages were just data being sent back and forth. Although this was simple to understand, the disadvantage is that you'd need to parse these messages and perform certain actions depending on its contents on your own.

Now every message has a type, that can be either a string or number. You can now listen for messages by type, directly tied to a callback for them.

This change is particularly useful for C#/Unity.

Error codes are exposed to the client-side during matchmaking:

Whenever you try to join into a room, many different errors can happen - the authentication may fail, the room may not exist anymore, or you may have an actual error in your "onJoin()" method in the server.

Previously, all these types of errors were returning just a "string", with the error message. Now, it returns an error object with both the error message and the proper "code" of the error. You can also throw your own custom codes if you'd like to.

New built-in room: LobbyRoom

Many people on Discord seem to be implementing their own version of a "realtime room listing lobby". The new built-in lobby room does exactly that. When rooms are created, updated, or destroyed - the lobby room is notified and sends the latest rooms for the clients in real-time. See docs for LobbyRoom.

New built-in room: RelayRoom

Ok, this built-in room was actually available on version 0.12 - but it seems it has more value now that you can send and listen to messages by type on version 0.13. See docs for RelayRoom.

The "client" on server-side has been reworked:

The "client" instance you see everywhere on the server-side used to be the raw WebSocket connection. Now, the WebSocket connection is wrapped in an internal structure from the framework. This was necessary to allow the new client.send() API, and it will be more useful in the future when we're going to implement new transport protocols, such as TCP while keeping the same APIs.

0.12.6

4 years ago
  • Add sismember function to presence (#321, thanks @carlosfusion)
  • Enhancement: auto-complete onCreate() argument type for gameServer.define()
  • Bug fix: keep client.auth after reconnection
  • Bug fix: spawning new rooms on processes with least amount of rooms

0.12.3

4 years ago

The this.allowReconnection() method now returns a Deferred instance, which can be manually canceled. The second argument is now optional. You can still await for the Deferred instance to complete (no breaking change).

Documentation: https://docs.colyseus.io/server/room/#allowreconnection-client-seconds

0.12.0

4 years ago

Version 0.12.0 has a few bug fixes, and a major breaking change in the way messages are sent and parsed internally.

Messaging protocol change

The server used to send TWO messages for all protocol messages. One with the protocol code (e.g. Protocol.ROOM_PATCH), and a second with the actual data. As of version 0.12, the first byte of the message is the protocol, and the rest is the actual data.

The broadcasts are slightly faster than before now.

Bug fixes

Small changes

0.11.24

4 years ago
  • (docs) Support for sending schema-encoded messages on this.send() and this.broadcast()
  • (docs) Enabled experimental state field filtering

0.11.18

4 years ago

Expose matchMaker as a module

You can now import the matchMaker singleton using:

import { matchMaker } from "colyseus";

This is useful for custom match-making routine when needed. E.g. custom ranked matchmaking as this example: https://github.com/endel/colyseus-ranked-matchmaking

If your code relies on gameServer.matchMaker, please import matchMaker from colyseus module instead, as this has been refactored.

0.11.17

4 years ago

0.11.13

4 years ago
  • Throw explicit "seat reservation expired" error instead of calling onJoin() with undefined values if seat reservation has expired (default 8 seconds)
  • Expose Room metadata type

Room's Metadata exposed

Explicitly defining the metadata allowed values:

interface Metadata {
  status: string;
}

class MyRoom extends Room<State, Metadata> {
  // ...
}

Retrieving typed listing with metadata:

const rooms = await client.getAvailableRooms<Metadata>("myroom");
rooms.forEach(room => {
  room.metadata.status // typescript knows this is a "string"
})

0.11.10

4 years ago

Removed the "donate" message on post-install

Due to the buzz of the funding project, and seeing other packages such as nodemon, pixijs, and webpack fighting for attention on the terminal, I've decided to remove the "donate" message on Colyseus.