Skip to content

Performance Tips

Export Room Settings

What is room settings?

It's a list of server-side and client-side commands. Once client connects to the room, it will receive the room settings from the server. This way, the client will know which commands are available in the room.

Why export room settings?

Storing room settings on the client side will reduce traffic for each connection.

How to export room settings?

Navigate to Project > Rooms > RoomName > Export and copy the JSON object.

Export Room Settings

There are two ways to hard-code room settings inside the client.

1. Using roomConfig in the client constructor:

javascript
let MRClient = new Client({
    ...

    roomConfig: {
        'room-alias-here': RoomConfigObject
    },
});

2. Or using setRoomConfig method after the client is created:

javascript
MRClient.setRoomConfig('room-alias-here', RoomConfigObject);

Example

javascript
let MRClient = new Client({
    ...
});

MRClient.setRoomConfig('game-room', {"serverCommands":{"MovePlayer":{"id":10,"params":[{"name":"commandId","type":"uint8"},{"name":"x","type":"uint32"},{"name":"y","type":"uint32"}]},"Ping":{"id":11,"params":[{"name":"commandId","type":"uint8"}]}},"clientCommands":{"Move":{"id":10,"params":[{"name":"commandId","type":"uint8"},{"name":"players","type":"array","array_of":"model:Player"}]},"ChangePlayerState":{"id":11,"params":[{"name":"commandId","type":"uint8"},{"name":"id","type":"string8"},{"name":"state","type":"bitArray8"}]},"Pong":{"id":12,"params":[{"name":"commandId","type":"uint8"},{"name":"number","type":"uint8"}]}},"models":{"Player":{"params":[{"name":"id","type":"string8"},{"name":"x","type":"uint32"},{"name":"y","type":"uint32"},{"name":"state","type":"bitArray8"}]}}});