public async void JoinRoom(string RoomName = "", GameRoomOptions options = null) { room = await client.Join <GameState>(RoomName, GetRoomOptions(options)); Debug.Log($"Joined Room [{RoomName}]!"); AttachRoomEvents(); }
public async Task CreateRoom(string RoomName = "", GameRoomOptions options = null) { if (client == null) { Debug.Log("Not connected to server!"); throw new Exception("Not connected to server"); } room = await client.Create <GameState>(RoomName, GetRoomOptions(options)); AttachRoomEvents(); Debug.Log($"Created Room: " + GetRoomId()); }
private Dictionary <string, object> GetRoomOptions(GameRoomOptions options) { var optionsDictionary = new Dictionary <string, object>(); if (options != null) { optionsDictionary.Add("isHost", options.isHost); optionsDictionary.Add("maxClients", options.maxClients); } else { optionsDictionary.Add("isHost", true); optionsDictionary.Add("maxClients", 5); } return(optionsDictionary); }