cryptomax
cryptomax10mo ago

What happens if two different Realtime instances connect to the same room at the same time??

What happens if two different Realtime instances connect to the same room name at the same time?
8 Replies
kapa.ai
kapa.ai10mo ago
Hi @cryptomax. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- If two different Realtime instances connect to the same room name at the same time, they will both end up connected to the same room server. This is because all clients that connect to the same room name will end up connected to the same room server, as mentioned in the Realtime API documentation (https://normcore.io/documentation/realtime). It's important to note that room names are namespaced to your App Key. Any room name used with a different App Key is considered a different room server by Normcore. This means that two Realtime instances using different App Keys would not connect to the same room server, even if they use the same room name. If you want to use multiple rooms in your multiplayer project, you can do so by creating additional Realtime instances. This is generally a good practice as it allows you to think of a Realtime instance as a connection to a single room (source (https://normcore.io/documentation/realtime/realtime)). Remember, you can connect to a room by calling the Connect() method along with the name of the room you would like to join. For example:
_realtime.Connect("My Room", new Room.ConnectOptions {
roomServerOptions = new Room.RoomServerOptions {
configuration = "medium"
}
});
_realtime.Connect("My Room", new Room.ConnectOptions {
roomServerOptions = new Room.RoomServerOptions {
configuration = "medium"
}
});
This code will instruct Realtime to connect to "My Room". If the room server is not already running, it will spin up a fresh room server using the "medium" configuration (source (https://normcore.io/documentation/room/room-server-options)). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai10mo ago
<@401986039964631060> kapa.ai is still learning and improving, please let us know how it did by reacting below
Mechabit
Mechabit10mo ago
I've tried this and you get duplicate avatars, obviously not what you want to do
cryptomax
cryptomaxOP10mo ago
one realtime would be data only
Mechabit
Mechabit10mo ago
then you use a postfix to change the room name like my_room_data it's what I do
cryptomax
cryptomaxOP10mo ago
what would be the distinction between post fixing it to another room name and connecting the same room name? Actually it is what I am doing currently as well, but I suddenly wondered what happens if it's just the same room name
Mechabit
Mechabit10mo ago
then you'll get all the same data duplicated the only way to do it is have 2 differen room names the postfix naming convention keeps things simple, you can use any 2 names
cryptomax
cryptomaxOP10mo ago
makes sense I will just append _data 👍

Did you find this page helpful?