– Implementing Metadata in C#

I’ve been investigating Colyseus for use in a new project and while I’ve had quick success getting everything working, their documentation is lacking. If you’ve got a Patreon page and you’re taking cash, then at the least keep your docs up to date. I shouldn’t have to dig through the individual example repos to find information about something language-specific that should be in docs.

Problem: The documentation on the Colyseus site says you can just do  room.metadata.whatever during a call to GetAvailableRooms(). You can’t. Metadata doesn’t exist for the RoomAvailable class the Colyseus Unity plugin provides.

Solution: You have to manually create the Serializable classes representing the metadata, by hand, mimicking the EXACT spelling that you use in the Server class. Why this can’t be done with the schema-codegen, I have no idea.

class Metadata
    public string playerDefinedRoomName;

class CustomRoomAvailable : RoomAvailable
    public Metadata metadata;


var rooms = await client.GetAvailableRooms<CustomRoomAvailable>();
var roomName = rooms[0].metadata.playerDefinedRoomName;

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.