Metadata is not readable on Unity3D client

As stated here, When trying to get AvailableRooms in the unity client, the metadata field does not deserialise correctly.

@gioragutt As of December 2019 this is still a problem. Someone made an attempt to start implementing this this, but that's all. Line 21 of Plugins/Colyseus/Client.cs clearly shows this.

Given how amazing Colyseus touts itself to be, I find it insulting that they'd have such a blatant lie/error in their documentation.

My advice to you, since you're using C# do what I'm going to do and just abandon it for something that works as advertised.

Proof.

Hi @MamaCatDev,

I've just replied on the original GitHub issue from @gioragutt, saying this:


As of 0.11.4, it is possible to retrieve the metadata from the client-side by defining a custom RoomAvailable + Metadata types.

Example:

[Serializable]
class Metadata
{
	public string mode;
	public string name;
}

[Serializable]
class CustomRoomAvailable : RoomAvailable
{
	public Metadata metadata;
}
var roomsAvailable = await client.GetAvailableRooms<CustomRoomAvailable>(roomName);

for (var i = 0; i < roomsAvailable.Length; i++)
{
    // getting metadata
    Debug.Log("metadata.mode: " + roomsAvailable[i].metadata.mode);
    Debug.Log("metadata.name: " + roomsAvailable[i].metadata.name);
}

The metadata comes from a JSON response from the server. Unfortunately, the built-in JsonUtility from Unity has limitations regarding the usage of generic types, making it necessary to create a new type having its own hardcoded Metadata type defined on it. (here's the method to decode the JSON response)

If you think the API can be improved please don't hesitate to share your thoughts.