I am exploring the correct flow for handling rooms & worlds -
i have a world where clients can meet up & go to a separate room for a minigame (like a dungeon in the MMO stated here:Rooms and Worlds | coherence Documentation)
What is the correct flow of handling this - should one client create the room and then send a command with the room info to the other clients, or is there a nicer way?
Yes, you have it right. Additionally if you need a little more coordination, you can use our Lobby system in the same way to have the people who would be joining the room associated with metadata, and then use the automatic Lobby room system to have them all enter the room automatically:
Reopening with more info and further questions since it’s related.
I did some light research now and current most stable flow is for me to:
Create room on 1 client:
**I wanted to avoid matchmaking & lobbies since all clients exist in a common world beforehand and they “matchmake” amongst themselves by inviting each other to rooms for 1 on 1 activities.
var roomService = bridge.CloudService.Rooms.GetRoomServiceForRegion("eu");
var roomOptions = new RoomCreationOptions
{
FindOrCreate = false,
MaxClients = 2,
};
var room = await roomService.CreateRoomAsync(roomOptions);
//send the new room uniqueID to other clients
otherPlayer.SendCommand<CustomCharacterController>(nameof(CustomCharacterController.JoinRoomFromData),
MessageTarget.AuthorityOnly, room.UniqueId);
//WAIT for at least 1 frame & then disconnect & join the new room.
GameManagerSystem.Instance.cohernceBridge.Disconnect();
GameManagerSystem.Instance.cohernceBridge.JoinRoom(room);
On the other client I:
var rooms = await roomsService.FetchRoomsAsync();
var room = rooms.FirstOrDefault(x => x.UniqueId == roomId);
I also explored encoding the endPointData since its what only really being used in the JoinRoom API and sending rest of room info is not really needed, however even with encoding it to byte it’s still over the message size limit.
Is there a smoother way I am missing completely or is this ok?
Thanks,
Fikus