GitHub Documentation

Room details

  • I'm newbie in Colyseus and i would like to say sorry for my poor English, I want create a play Cards game with Node.js and HTML.
    I have some question :
    How can i get count of user exist in the room?
    How can i get name and link of rooms ?

  • @h4ss4n answer of my first question: This variable _maxClientsReached hold status of room .

  • This is how I do it (in HaXe)

    Client Side : Joining/Create a room with options where I add the variable RoomName

    	var theOptions:Map<String, Dynamic>=new Map<String,Dynamic>();
    	theOptions.set("RoomName", ""+RoomName);

    Client Side (getAvailableRooms) this will give you a list off all roomnames created

    	client.getAvailableRooms(room_type, function(rooms, ?err) {
    		if (err != null) trace("ERROR! " + err);
    		for (room in rooms) {
    trace(" room ID: "+room.roomId+" room Name: "+room.metadata.RoomName);

    Server Side :

    override function onInit (options:Dynamic) {
    trace("Lobby created!", options);
            setMetadata(options); // is from Room documentation:

  • @mdotedot Thanks for your response it's great!

  • @mdotedot
    How can I set setMetadata on server and client ?

    I try below Code but didn't work and receive this Error from browser
    "Uncaught TypeError: room.setMetadata is not a function
    at create (04-create-or-join-room.html:70)
    at HTMLButtonElement.onclick (04-create-or-join-room.html:30)"

    client side (Local):

    function create () {
         room = client.join('create_or_join', { create: true });

    Client side (Server):

        console.log("setMetadata ");

    Do you have any suggestion ?

  • administrator

    Hi @h4ss4n, the room metadata can be set only on server-side, and it's available for the client-side only for room listing (using getAvailableRooms() method)

  • @endel Thanks for your answer . I use this solution for set data to setMetadata and This code work well:

    Client side (local):

    room = client.join('create_or_join', { create: true, name:'hi2020', gametype:1 });

    Server side (TS file):

    onInit (options) {
    gametype: options.gametype,


© 2021 Lucid Sight, Inc