private static void TestConsumer(GameApi api, PlayersApi players, Configuration config) { GameRules rules = new GameRules(true, 2, "Test", 1, password: null); PrintHeader("Create Game"); int game = api.CreateGame(rules); Print("Game ID: " + game); Print("Stats : " + api.GetGameState(game)); PrintHeader("Join Game"); players.Join(game); ConsumerApi consumerApi = new ConsumerApi(config); JoinResponse response = consumerApi.RegisterConsumer(game, new ConsumerRegistration("Test", "Ein consumer")); Print($"id : {response.Id}"); Print($"pat : {response.Pat}"); players.Configuration.ApiKey["pat"] = response.Pat; api.Configuration.ApiKey["pat"] = response.Pat; config.ApiKey["pat"] = response.Pat; JoinResponse somePlayer = players.Join(game); Print(players.GetPlayer(game, somePlayer.Id).ToJson()); PrintHeader("Start Game"); api.CommitAction(game, ActionType.STARTGAME); PrintHeader("Fetch Events"); EventHandlingApi eventApi = new EventHandlingApi(config); for (int i = 0; i < 8; i++) { Print(eventApi.FetchNextEvent(game).Type.ToString()); } }
IEnumerator iLeave() { WWWForm form = new WWWForm(); form.AddField("playerID", m_joinResponse.playerID); form.AddField("gameID", m_joinResponse.gameID); UnityWebRequest www = UnityWebRequest.Post(m_host + "/game/leave", form); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { m_active = false; m_lastSeen = 0; m_joinResponse = new JoinResponse(); m_gameActionQueue = new Queue <GameAction>(); yield return(iJoinLobby()); } }
private IEnumerator participate(int teamId) { int gameId = (int)PhotonNetwork.room.customProperties["gameId"]; WWWForm partForm = new WWWForm(); partForm.AddField("gameId", gameId); partForm.AddField("teamId", teamId); partForm.AddField("token", LoginManager.getToken()); WWW join = new WWW(DataServerDomain.url + "join", partForm.data); yield return(join); JoinResponse response = JsonUtility.FromJson <JoinResponse>(join.text); if (response.status != 200) { Debug.LogError("Failed to join game"); PhotonNetwork.Disconnect(); LoginManager.clear(); } else { Debug.Log("Joined game with gameId:" + gameId); } }
public void TestHandleJoin() { string uid = "uid"; string userName = "******"; string gameName = "game"; MessagePackets messages = JoinGame(uid, userName, gameName); List <Player> players = gm.GetPlayers(); Assert.AreEqual(players.Count, 1); Assert.AreEqual(players.Last().Name, userName); Assert.AreEqual(players.Last().Uid, uid); Assert.IsTrue(Utils.VerifyMessagePackets(messages, typeof(JoinResponse), typeof(JoinMessage))); JoinResponse jr = (JoinResponse)messages.Messages[0].Message; Assert.AreEqual(messages.Messages[0].SendTo.Count(), 1); Assert.AreEqual(messages.Messages[0].SendTo.Single(), uid); Assert.AreEqual(jr.UserName, userName); Assert.AreEqual(jr.ErrorMessage, null); Assert.IsTrue(jr.Success); JoinMessage jm = (JoinMessage)messages.Messages[1].Message; Assert.AreEqual(messages.Messages[1].SendTo.Count(), 1); Assert.AreEqual(messages.Messages[1].SendTo.Single(), uid); Assert.AreEqual(jm.UserName, userName); Assert.AreEqual(jm.GameName, gameName); Assert.AreEqual(jm.Order, 0); }
/// <summary> /// Join response /// </summary> /// <param name="response"></param> private void OnJoinResponse(JoinResponse response) { if (response.Success) { AlmiranteEngine.Scenes.Switch <Play>(); } else { this.message_label.Text = response.Message; this.message_panel.Visible = true; } }
private void HandleJoinResponse(JoinResponse joinResponse) { if (joinResponse.Success) { PlayerName = joinResponse.UserName; ViewController.Instance.ShowGameTable(true); ViewController.Instance.UpdateLog(SystemString, "The game will start once enough players have joined."); ViewController.Instance.HideJoinWindow(); } else { ViewController.Instance.SetJoinError(joinResponse.ErrorMessage); } }
// Use this for initialization void Start() { StarXClient client = new StarXClient(); client.Init("127.0.0.1", 3250, () => { Debug.Log("init client callback"); client.Connect((data) => { Debug.Log("connect client callback"); // 服务器主动推送消息 client.On("onNewUser", (m) => { NewUser nu = NewUser.Parser.ParseFrom(m); Debug.Log("onNewUser: "******"onMembers", (m) => { AllMembers am = AllMembers.Parser.ParseFrom(m); Debug.Log("onMembers: " + am.Members); }); client.On("onMessage", (m) => { Testdata.UserMessage um = UserMessage.Parser.ParseFrom(m); Debug.Log("onMessage: " + um.Name + " : " + um.Content); }); //客户端请求,服务器回答 Testdata.Ping first = new Testdata.Ping { Content = "hello" }; client.Request("room.join", first.ToByteArray(), (resp) => { JoinResponse jp = JoinResponse.Parser.ParseFrom(resp); Debug.Log("room.join response: " + jp.Result); }); // 客户端推送,没有回消息 UserMessage msg = new UserMessage { Name = "小明", Content = "我来了" }; client.Notify("room.message", msg.ToByteArray()); }); }); }
void OnEnable() { // gRPC サーバの TCP リスナー先を指定して、 // RoomClient クライアントとして接続を行う channel = new Channel("localhost:50051", ChannelCredentials.Insecure); client = new World.Room.RoomClient(channel); // gRPC サーバの Join を実行し、指定した部屋からユーザの ID を発行してもらう JoinResponse response = client.Join(new JoinRequest { RoomId = this.roomID }); // 発行されたユーザの ID は変数で保持しておく this.userID = response.UserId; }
public void OnSocketMessage(IWebSocketConnection connection, byte[] data) { //if user has already logged in if (joinedUsers.ContainsKey(connection)) { var message = MessageToServer.Parser.ParseFrom(data); var user = joinedUsers[connection]; //if message is of type Chat if (message.MessageCase == MessageToServer.MessageOneofCase.ChatToServer) { var outgoingChat = new MessageFromServer(); outgoingChat.ChatFromServer = new MessageFromServer.Types.Chat { Name = user.Name, Trip = user.Trip, Text = message.ChatToServer.Text }; Log.LogInfo($"{user.Name} @{user.Room.Name} {user.Trip} : {message.ChatToServer}"); //send message to all users in that person's room joinedUsers[connection].Room.Send(outgoingChat); } } else { //this is a new user joining for the first time var joinMessage = Join.Parser.ParseFrom(data); //the room the the new user is joining var room = GetRoom(joinMessage.Room); var newUser = new User(connection, joinMessage.Name, joinMessage.Password, GetRoom(joinMessage.Room)); joinedUsers.Add(connection, newUser); room.AddUser(newUser); //send a success response back to the new client var joinResponse = new JoinResponse { Success = new JoinResponseSuccessful() }; joinResponse.Success.OnlineUsers.Add(room.Users.Select(roomUser => roomUser.Name).ToList()); Console.WriteLine("size: " + joinResponse.CalculateSize()); connection.Send(joinResponse.ToByteArray()); Log.LogInfo($"{newUser.Name} @ {newUser.Room.Name} {newUser.Trip} joined"); } }
public virtual IActionResult RegisterConsumer([FromRoute(Name = "game_id")][Required][Range(0, 2048)] int gameId, [FromBody] ConsumerRegistration consumerRegistration) => new GameRequestPipeline() .Game(gameId) .Compute(code: c => { JoinResponse response = c.Game.RegisterConsumer(consumerRegistration); if (response == null) { c.Response = StatusCode(410); } else { c.Response = new ObjectResult(response); } }) .ExecuteAction();
IEnumerator iJoinLobby() { WWWForm form = new WWWForm(); UnityWebRequest www = UnityWebRequest.Post(m_host + "/lobby/join", form); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { m_joinResponse = JsonUtility.FromJson <JoinResponse> (www.downloadHandler.text); Game game = m_game.GetComponent <Game>(); game.SetLocal(m_joinResponse.playerNumber); StartCoroutine(heartbeat()); } }
public void TestHandleJoinExistingGame() { string uid = "uid"; string userName = "******"; CreateExistingGame(); MessagePackets messages = JoinGame(uid, userName, ExistingGameName); List <Player> players = gm.GetPlayers(); Assert.AreEqual(players.Count, 2); Assert.AreEqual(players.Last().Name, userName); Assert.AreEqual(players.Last().Uid, uid); Assert.IsTrue(Utils.VerifyMessagePackets(messages, typeof(JoinResponse), typeof(JoinMessage), typeof(JoinMessage))); JoinResponse jr = (JoinResponse)messages.Messages[0].Message; Assert.AreEqual(messages.Messages[0].SendTo.Count(), 1); Assert.AreEqual(messages.Messages[0].SendTo.Single(), uid); Assert.AreEqual(jr.UserName, userName); Assert.AreEqual(jr.ErrorMessage, null); Assert.IsTrue(jr.Success); JoinMessage jm1 = (JoinMessage)messages.Messages[1].Message; Assert.AreEqual(messages.Messages[1].SendTo.Count(), 1); Assert.AreEqual(messages.Messages[1].SendTo.Single(), uid); Assert.AreEqual(jm1.UserName, ExistingUserName); Assert.AreEqual(jm1.GameName, ExistingGameName); Assert.AreEqual(jm1.Order, 0); JoinMessage jm2 = (JoinMessage)messages.Messages[2].Message; Assert.AreEqual(messages.Messages[2].SendTo.Count(), 2); CollectionAssert.AreEqual(messages.Messages[2].SendTo.ToList(), new List <string>() { ExistingUid, uid }); Assert.AreEqual(jm2.UserName, userName); Assert.AreEqual(jm2.GameName, ExistingGameName); Assert.AreEqual(jm2.Order, 1); }
private static void TestStartGame(GameApi api, PlayersApi players, Configuration config) { GameRules rules = new GameRules(true, 2, "Test", 1, password: null); PrintHeader("Create Game"); int game = api.CreateGame(rules); Print("Game ID: " + game); Print("Stats : " + api.GetGameState(game)); PrintHeader("Join Game"); JoinResponse response = players.Join(game); Print($"id : {response.Id}"); Print($"pat : {response.Pat}"); players.Configuration.ApiKey["pat"] = response.Pat; api.Configuration.ApiKey["pat"] = response.Pat; config.ApiKey["pat"] = response.Pat; players.Join(game); Print(players.GetPlayer(game, response.Id).ToJson()); PrintHeader("Start Game"); api.CommitAction(game, ActionType.STARTGAME); PrintHeader("Fetch Events"); EventHandlingApi eventApi = new EventHandlingApi(config); bool run = true; int c = 1; try { while (run) { EventType type = eventApi.TraceEvent(game, wait: true, batch: false)[0]; run = type != EventType.Gameendevent; GenericEvent ev = eventApi.FetchNextEvent(game); Print(c++ + ". Event: " + type); Print(ev.ToJson() + "\n"); } } catch (Exception) { Console.Out.WriteLine("TraceEvent(" + game + ")"); throw; } }
void ProcJoin() { // Connect to arbitrary node in the ring ProcConnect(); // Make a join request OutputManager.Ui.Write("Join Request..."); JoinRequest joinRequest = new JoinRequest(this.localNode); Message joinResponseTmp = localNode.SendMessage(joinRequest); JoinResponse joinResponse = new JoinResponse(joinResponseTmp.ToString()); // Disconnect from the arbitary node in the ring OutputManager.Ui.Write("Disconnecting from node..."); localNode.DisconnectFromNode(); // Update local node connection info OutputManager.Ui.Write("Updating local info..."); localNode.predNode = new ChordNode(joinResponse.predIpAddress, joinResponse.predPort, joinResponse.predId); localNode.succNode = new ChordNode(joinResponse.succIpAddress, joinResponse.succPort, joinResponse.succId); // Connect to pred OutputManager.Ui.Write("Connecting to pred..."); localNode.ConnectToNode(localNode.predNode.IpAddress, localNode.predNode.Port); // Have pred update their succ OutputManager.Ui.Write("Having pred update their succ..."); UpdateSuccNodeRequest uSuccRequest = new UpdateSuccNodeRequest(this.localNode, this.localNode); Message uSuccResponseTmp = localNode.SendMessage(uSuccRequest); UpdateNodeResponse uSuccResponse = new UpdateNodeResponse(uSuccResponseTmp.ToString()); // TODO: Ensure that update was successful // Disconnect from pred OutputManager.Ui.Write("Disconnecting from pred..."); localNode.DisconnectFromNode(); // Connect to succ OutputManager.Ui.Write("Connecting to succ..."); localNode.ConnectToNode(localNode.succNode.IpAddress, localNode.succNode.Port); // Have succ update their pred OutputManager.Ui.Write("Having succ update their pred..."); UpdatePredNodeRequest uPredRequest = new UpdatePredNodeRequest(this.localNode, this.localNode); UpdateNodeResponse uPredResponse = (localNode.SendMessage(uPredRequest)) as UpdateNodeResponse; // TODO: Ensure that update was successful OutputManager.Ui.Write("Successfully joined to ring!"); // TODO: Get resources that should now belong to this node from succ node }
public void TestHandleJoinDuplicateUserName() { string uid = "uid"; CreateExistingGame(); Assert.AreEqual(gm.GetPlayers().Count, 1); MessagePackets messages = JoinGame(uid, ExistingUserName, ExistingGameName); Assert.AreEqual(gm.GetPlayers().Count, 1); Assert.IsTrue(Utils.VerifyMessagePackets(messages, typeof(JoinResponse))); JoinResponse jr = (JoinResponse)messages.Messages[0].Message; Assert.AreEqual(messages.Messages[0].SendTo.Count(), 1); Assert.AreEqual(messages.Messages[0].SendTo.Single(), uid); Assert.AreEqual(jr.UserName, null); Assert.AreNotEqual(jr.ErrorMessage, null); Assert.IsFalse(jr.Success); }
public async Task <APIGatewayProxyResponse> JoinHandler(APIGatewayProxyRequest request, ILambdaContext context) { try { var connectionId = request.RequestContext.ConnectionId; var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true, }; JoinRequest doc = JsonSerializer.Deserialize <JoinRequest>(request.Body, options); string roomId = await DDBUtils.GenerateNormalRoom(doc.User1ID, doc.User2ID, connectionId); JoinResponse responseMsg = new JoinResponse() { RoomName = "Conversation with " + doc.User2ID, RoomID = roomId, Success = true }; return(new APIGatewayProxyResponse { StatusCode = 200, Body = JsonSerializer.Serialize(responseMsg) }); } catch (Exception e) { context.Logger.LogLine("Error joining room: " + e.Message); context.Logger.LogLine(e.StackTrace); JoinResponse responseMsg = new JoinResponse() { Success = false }; return(new APIGatewayProxyResponse { StatusCode = 500, Body = JsonSerializer.Serialize(responseMsg) }); } }
private Any CreateJoinResponse(PlayerJoinRequest request) { try { var loginTokenResp = _playerAuthServiceClient.CreateLoginToken(new CreateLoginTokenRequest { DeploymentId = request.DeploymentId, PlayerIdentityToken = request.PlayerIdentityToken }); var response = new JoinResponse { DeploymentName = request.DeploymentName, LoginToken = loginTokenResp.LoginToken }; return(Any.Pack(response)); } catch (Exception e) { Log.Error(e, "encountered an error creating a login token"); throw new RpcException(new Status(StatusCode.Internal, "encountered an error creating a login token")); } }
public async Task <JsonResult> Post() { JsonResult response; try { JoinResponse joinResponse = await gameApiService.JoinCurrentRound(User.Identity.Name); joinResponse.RequestId = requestContext.RequestId; response = new JsonResult(joinResponse) { StatusCode = 200 }; } catch (Exception) { logger.LogError($"Error Occurred while fetching current gamestatus"); response = new JsonResult(new JoinResponse { RequestId = requestContext.RequestId, Err = new Error { Message = "Internal Server Error", Description = "Server Failed to fetch Current Gamestatus" }, Data = new JoinResponseData { Joined = false } }) { StatusCode = 500 }; } return(response); }
public void OnJoinResponse(JoinResponse package) { _stateHandler.EntityManager.AddEntity(package.CharacterId, package.CharacterName, GameObject.GameObjectType.Player, GameObject.GameObjectSubType.LocalPlayer); }
/// <summary> /// Handles the <see cref = "JoinRequest" />: Joins a peer to a room and calls <see cref = "PublishJoinEvent" />. /// Before a JoinOperation reaches this point (inside a room), the <see cref = "LitePeer" /> made /// sure that it is removed from the previous Room (if there was any). /// </summary> /// <param name = "peer"> /// The peer. /// </param> /// <param name = "joinRequest"> /// The join operation. /// </param> /// <param name = "sendParameters"> /// The send Parameters. /// </param> /// <returns> /// The newly created (joined) actor or null if the peer already joined. /// </returns> protected virtual Actor HandleJoinOperation(LitePeer peer, JoinRequest joinRequest, SendParameters sendParameters) { if (this.IsDisposed) { // join arrived after being disposed - repeat join operation if (Log.IsWarnEnabled) { Log.WarnFormat("Join operation on disposed game. GameName={0}", this.Name); } return(null); } if (Log.IsDebugEnabled) { Log.DebugFormat("Join operation from IP: {0} to port: {1}", peer.RemoteIP, peer.LocalPort); } // create an new actor Actor actor; if (this.TryAddPeerToGame(peer, joinRequest.ActorNr, out actor) == false) { peer.SendOperationResponse( new OperationResponse { OperationCode = joinRequest.OperationRequest.OperationCode, ReturnCode = -1, DebugMessage = "Peer already joined the specified game." }, sendParameters); return(null); } // check if a room removal is in progress and cancel it if so if (this.RemoveTimer != null) { this.RemoveTimer.Dispose(); this.RemoveTimer = null; } // set game properties for join from the first actor (game creator) if (this.Actors.Count == 1) { this.DeleteCacheOnLeave = joinRequest.DeleteCacheOnLeave; this.SuppressRoomEvents = joinRequest.SuppressRoomEvents; if (joinRequest.GameProperties != null) { this.Properties.SetProperties(joinRequest.GameProperties); } } // set custom actor properties if defined if (joinRequest.ActorProperties != null) { actor.Properties.SetProperties(joinRequest.ActorProperties); } // set operation return values and publish the response var joinResponse = new JoinResponse { ActorNr = actor.ActorNr }; if (this.Properties.Count > 0) { joinResponse.CurrentGameProperties = this.Properties.GetProperties(); } foreach (Actor t in this.Actors) { if (t.ActorNr != actor.ActorNr && t.Properties.Count > 0) { if (joinResponse.CurrentActorProperties == null) { joinResponse.CurrentActorProperties = new Hashtable(); } Hashtable actorProperties = t.Properties.GetProperties(); joinResponse.CurrentActorProperties.Add(t.ActorNr, actorProperties); } } peer.SendOperationResponse(new OperationResponse(joinRequest.OperationRequest.OperationCode, joinResponse), sendParameters); // publish join event this.PublishJoinEvent(peer, joinRequest); this.PublishEventCache(peer); return(actor); }
private void HandleMessage(string message) { try { lock (MessageTasks) { ErrorResponse errorResponse = JsonConvert.DeserializeObject <ErrorResponse>(message); if (errorResponse.IsValid()) { Debug.Log("ErrorResponse: " + errorResponse.ErrorMessage); return; } DisconnectMessage disconnectMessage = JsonConvert.DeserializeObject <DisconnectMessage>(message); if (disconnectMessage.IsValid()) { HandleDisconnect(disconnectMessage); return; } RestartMessage restartMessage = JsonConvert.DeserializeObject <RestartMessage>(message); if (restartMessage.IsValid()) { HandleRestart(restartMessage); return; } GameTypeMessage gameTypeMessage = JsonConvert.DeserializeObject <GameTypeMessage>(message); if (gameTypeMessage.IsValid()) { ViewController.Instance.UpdateGameTypes(gameTypeMessage.GameTypes); return; } JoinResponse joinResponse = JsonConvert.DeserializeObject <JoinResponse>(message); if (joinResponse.IsValid()) { HandleJoinResponse(joinResponse); return; } AvailableGamesMessage gamesMessage = JsonConvert.DeserializeObject <AvailableGamesMessage>(message); if (gamesMessage.IsValid()) { ViewController.Instance.UpdateAvailableGames(gamesMessage.AvailableGames); return; } JoinMessage joinMessage = JsonConvert.DeserializeObject <JoinMessage>(message); if (joinMessage.IsValid()) { HandleJoin(joinMessage); return; } StartMessage startMessage = JsonConvert.DeserializeObject <StartMessage>(message); if (startMessage.IsValid()) { HandleStart(startMessage); return; } BidMessage bidMessage = JsonConvert.DeserializeObject <BidMessage>(message); if (bidMessage.IsValid()) { HandleBid(bidMessage); return; } KittyMessage kittyMessage = JsonConvert.DeserializeObject <KittyMessage>(message); if (kittyMessage.IsValid()) { HandleKitty(kittyMessage); return; } TrumpMessage trumpMessage = JsonConvert.DeserializeObject <TrumpMessage>(message); if (trumpMessage.IsValid()) { HandleTrump(trumpMessage); return; } MeldPointsMessage meldPointsMessage = JsonConvert.DeserializeObject <MeldPointsMessage>(message); if (meldPointsMessage.IsValid()) { HandleMeldPoints(meldPointsMessage); return; } MeldMessage meldMessage = JsonConvert.DeserializeObject <MeldMessage>(message); if (meldMessage.IsValid()) { HandleMeld(meldMessage); return; } PassMessage passMessage = JsonConvert.DeserializeObject <PassMessage>(message); if (passMessage.IsValid()) { HandlePass(passMessage); return; } ScoreMessage scoreMessage = JsonConvert.DeserializeObject <ScoreMessage>(message); if (scoreMessage.IsValid()) { HandleScore(scoreMessage); return; } TurnMessage turnMessage = JsonConvert.DeserializeObject <TurnMessage>(message); if (turnMessage.IsValid()) { HandleTurn(turnMessage); return; } TrickMessage trickMessage = JsonConvert.DeserializeObject <TrickMessage>(message); if (trickMessage.IsValid()) { HandleTrick(trickMessage); return; } TrickInfoMessage trickInfoMessage = JsonConvert.DeserializeObject <TrickInfoMessage>(message); if (trickInfoMessage.IsValid()) { HandleTrickInfo(trickInfoMessage); return; } GameOverMessage gameOverMessage = JsonConvert.DeserializeObject <GameOverMessage>(message); if (gameOverMessage.IsValid()) { HandleGameOver(gameOverMessage); return; } } } catch (Exception err) { Debug.Log("OnMessage error: " + err.Message); Debug.Log("OnMessage stack trace: " + err.StackTrace); } }
public virtual async Task <JoinResponse> JoinCurrentRound(string teamId) { JoinResponse response = new JoinResponse(); if (string.IsNullOrWhiteSpace(teamId)) { response.Err = new Error { Message = "Invalid Username", Description = "Failed to parse username from authorization header" }; return(response); } var currentPhase = await _context.Phases.Include(p => p.Round).OrderByDescending(p => p.TimeStamp).FirstOrDefaultAsync(); if (currentPhase == null) { response.Err = new Error { Message = "Try after some time", Description = "Game is not running" }; } else if (!currentPhase.PhaseType.Equals(PhaseType.Joining)) { response.Err = new Error { Message = "Failed to Join the Round", Description = "Round is not in Joining phase" }; } else { var existingParticipant = await _context.Participants.Where(p => p.TeamId == teamId.ToLowerInvariant() && p.RoundId.CompareTo(currentPhase.RoundId) == 0).SingleOrDefaultAsync(); var roundConfig = await _context.RoundConfigs.Where(rc => rc.Id == currentPhase.Round.RoundNumber).SingleOrDefaultAsync(); if (existingParticipant == null) { await _context.Participants.AddAsync(new Participant { GameId = currentPhase.GameId, RoundId = currentPhase.RoundId, IsAlive = true, TeamId = teamId.ToLowerInvariant(), Secret = GenerateSecret(roundConfig?.SecretLength), JoinedAt = DateTime.UtcNow }); await _context.Scores.AddAsync(new Score { GameId = currentPhase.GameId, RoundId = currentPhase.RoundId, PointsScored = 0, TimeStamp = DateTime.UtcNow, TeamId = teamId.ToLowerInvariant() }); await _context.SaveChangesAsync(); } else { response.Err = new Error { Message = "Can't Join Again", Description = "You have already joined the round" }; } response.Data = new JoinResponseData { Joined = true }; } if (response.Err != null) { response.Data = new JoinResponseData { Joined = false } } ; if (response.Data != null && currentPhase != null) { var responseData = response.Data; responseData.GameId = currentPhase.GameId; responseData.RoundId = currentPhase.RoundId; responseData.RoundNumber = currentPhase.Round.RoundNumber; responseData.Status = currentPhase.PhaseType.ToString(); } return(response); }