public void LeaveGame() { LeaveGameRequest request = new LeaveGameRequest(ClientID); SendMessage(request); ClientState = ClientStates.Login; }
public void CanDoSomething() { var request = new LeaveGameRequest {ProfileId = "Prof1", GameId = "123"}; var handler = new LeaveGameRequestHandler(_gameRepo.Object); var response = handler.Handle(request); _gameRepo.Verify(x => x.RemovePlayerFromGame(request.ProfileId, request.GameId)); Assert.That(response.Status, Is.EqualTo(ResponseCodes.Success)); }
public void HandleLeaveGameRequest(LeaveGameRequest request) { Console.WriteLine("LeaveGameRequest " + JsonConvert.SerializeObject(request)); LeaveGameResponse response = new LeaveGameResponse() { Success = true, ResponseId = request.RequestId }; Send(response); }
public void OnLeaveGame(LeaveGameRequest request, long clientId) { var roleId = ManagerMediator.RoleManager.GetRoleIdByClientId(clientId); var desk = _room.GetDesk(_room.GetRoleDesk(roleId)); if (desk != null) { if (desk.GameLogic is IInnerMail innerMail) { innerMail.OnLeaveGame(request, clientId); } desk.RemoveRole(roleId); if (desk.RoleCount() == 0) { _room.RemoveDesk(desk.DeskId); } _room.RemoveRoleDesk(roleId); } }
private void OnLeaveDeskRequest(MailPacket mail) { var stoc = new ClientServerProto.StoCLeaveDeskReply(); var roleId = ManagerMediator.RoleManager.GetRoleIdByClientId(mail.ClientId); var deskId = _room.GetRoleDesk(roleId); if (deskId != 0) { var desk = _room.GetDesk(deskId); if (desk != null) { if (desk.GameLogic is IInnerMail innerMail) { var request = new LeaveGameRequest { UserId = mail.UserId }; innerMail.OnLeaveGame(request, mail.ClientId); } desk.RemoveRole(roleId); if (desk.RoleCount() == 0) { _room.RemoveDesk(desk.DeskId); } _room.RemoveRoleDesk(roleId); } } else { stoc.Result = new ClientServerProto.ReplayResult { ErrorCode = 1, ErrorInfo = "不在座位上" }; } Dispatcher.WriteAgentMail(new MailPacket { Id = (int)ClientServerProto.MessageId.StoCleaveDeskReplyId, Content = stoc.ToByteArray(), Reserve = mail.Reserve, UserId = mail.UserId, ClientId = mail.ClientId }); }
private void BackBTN_Click(object sender, RoutedEventArgs e) { LeaveGameRequest leaveGameRequest = new LeaveGameRequest(); app.communicator.SocketSendReceive(JsonSerializer.serializeRequest(leaveGameRequest, Constants.LEAVE_GAME_REQUEST)).ContinueWith(task => { ResponseInfo response = task.Result; LeaveGameResponse leaveGameResponse = JsonDeserializer.deserializeResponse <LeaveGameResponse>(response.buffer); switch (leaveGameResponse.status) { case Constants.LEAVE_GAME_SUCCESS: thr.Abort(); MyMessageQueue.Enqueue("You left the game successfuly."); this.Dispatcher.Invoke(() => { NavigationService ns = NavigationService.GetNavigationService(this); ns.Navigate(new Uri("Menu.xaml", UriKind.Relative)); }); break; } }); }
public void OnLeaveGame(LeaveGameRequest request, long clientId) { //throw new NotImplementedException(); }
public void OnLeaveGameRequest(LeaveGameRequest r) { OnLeaveGame(r.clientId); }