Join network room without changing the url

Is it possible to make join a certain room without getting url updated? It becomes easy for anyone to see the room name from the url.

Hi Saad Baig,

To join a network room without updating the URL, you can modify the behavior of the SyncedRoom component. Specifically, you want to bypass the URL parameter handling when joining a room.

Modify your tryJoinRoom method in the SyncedRoom class to avoid setting the room name from the URL. Instead, set the room name programmatically when you want to join:

class SyncedRoom extends Behaviour {
    // Existing properties...

    tryJoinRoom() {
        // Bypass URL handling for room name
        this.roomName = "yourRoomName"; // Set the desired room name
        this.context.connection.joinRoom(this.roomName);
    }
}

By hardcoding or setting the room name programmatically, you prevent it from being reflected in the URL.

Alternatively, you could modify how the URL parameters are processed. If you want to keep the existing logic but conditionally update the URL only in certain circumstances, you might want to implement a check before any URL manipulation occurs.

If you require further modifications or have specific conditions in mind for managing room states, feel free to ask!

For more details about SyncedRoom, you can check out the relevant documentation regarding its methods and properties. (see the documentation)】

3 replies left
thread_eThTJjmEOaHHi7RARINLmKi8
Reply to this message to continue the conversation

This topic was automatically closed 13 days after the last reply. New replies are no longer allowed.