internal async Task JoinOrCreate(string roomName, RoomOptions roomOptions, List <string> expectedUserIds) { state = State.Joining; try { LobbyInfo lobbyInfo = await Client.lobbyService.Authorize(); LobbyRoomResult lobbyRoom = await Client.lobbyService.JoinRoom(roomName, null, false, true); gameConn = new GameConnection(); await gameConn.Connect(Client.AppId, lobbyRoom.Url, Client.GameVersion, Client.UserId, lobbyInfo.SessionToken); Protocol.RoomOptions options; if (lobbyRoom.Create) { options = await gameConn.CreateRoom(lobbyRoom.RoomId, roomOptions, expectedUserIds); } else { options = await gameConn.JoinRoom(lobbyRoom.RoomId, null); } Init(options); state = State.Game; } catch (Exception e) { state = State.Closed; throw e; } }
internal async Task JoinRandom(PlayObject matchProperties, List <string> expectedUserIds) { state = State.Joining; try { LobbyInfo lobbyInfo = await Client.lobbyService.Authorize(); LobbyRoomResult lobbyRoom = await Client.lobbyService.JoinRandomRoom(matchProperties, expectedUserIds); gameConn = new GameConnection(); await gameConn.Connect(Client.AppId, lobbyRoom.Url, Client.GameVersion, Client.UserId, lobbyInfo.SessionToken); Protocol.RoomOptions options = await gameConn.JoinRoom(lobbyRoom.RoomId, expectedUserIds); Init(options); state = State.Game; } catch (Exception e) { state = State.Closed; throw e; } }
internal async Task Rejoin(string roomName) { state = State.Joining; try { LobbyInfo lobbyInfo = await Client.lobbyService.Authorize(); LobbyRoomResult lobbyRoom = await Client.lobbyService.JoinRoom(roomName, null, true, false); gameConn = new GameConnection(); await gameConn.Connect(Client.AppId, lobbyRoom.Url, Client.GameVersion, Client.UserId, lobbyInfo.SessionToken); Protocol.RoomOptions options = await gameConn.JoinRoom(lobbyRoom.RoomId, null); Init(options); state = State.Game; } catch (Exception e) { state = State.Closed; throw e; } }