private static void LEAVE_ROOM(byte[] bytes) { LeaveRoom input = LeaveRoom.Parser.ParseFrom(bytes); bool ret = false; RoomLogic roomLogic = ServerRoomManager.Instance.GetRoomLogic(input.RoomId); if (roomLogic != null) { var pi = ServerRoomManager.Instance.GetPlayer(_args); if (pi != null) { // 把当前玩家在房间的状态设置为离线 roomLogic.Offline(pi.Enter.TokenId); string account = pi.Enter.Account; ServerRoomManager.Instance.Log($"MSG: LEAVE_ROOM OK - Player leaves the battlefield! Account:{account} - Room:{roomLogic.RoomName}"); // 玩家离开战场! } // 通知大厅 ServerRoomManager.Instance.UpdateRoomInfoToLobby(roomLogic); ret = true; } else { ServerRoomManager.Instance.Log($"MSG: LEAVE_ROOM Error - Battlefield is not found! RoomId:{input.RoomId}"); // 战场没有找到 } LeaveRoomReply output = new LeaveRoomReply() { Ret = ret, }; ServerRoomManager.Instance.SendMsg(_args, ROOM_REPLY.LeaveRoomReply, output.ToByteArray()); }
void OnDestroy() { Completed -= OnComplete; Received -= OnReceiveMsg; // 退出的时候, 最后尝试一下看消息能否发出 LeaveRoom output = new LeaveRoom() { RoomId = RoomId, ReleaseIfNoUser = true, }; SendMsg(ROOM.LeaveRoom, output.ToByteArray()); RoomLogic.Fini(); }
public override async Task OnDisconnectedAsync(Exception exception) { var context = Context.GetHttpContext(); var id = context.Request.Query["access_token"]; await Unsubscribe(id); var command = new LeaveRoom(); command.RoomId = Guid.Parse(id); command.ConnectionId = Context.ConnectionId; await DispatchAsync(command); await _roomListHub.SendToAllAsync("left", new { roomId = command.Result.RoomId, numberOfPlayers = command.Result.NumberOfPlayers }); await SendToGroupAsync(id, "left", command.Result); }
public void OnClickExit() { LeaveRoom output = new LeaveRoom() { RoomId = GameRoomManager.Instance.RoomId, ReleaseIfNoUser = true, }; if (GameRoomManager.Instance) { GameRoomManager.Instance.SendMsg(ROOM.LeaveRoom, output.ToByteArray()); } if (ClientManager.Instance != null) { ClientManager.Instance.StateMachine.TriggerTransition(ConnectionFSMStateEnum.StateEnum.RESULT); } }
public void EndAll() { Bg.Dispose(); gold.Dispose(); EncWumpus.Dispose(); EncPit.Dispose(); EnterRoom.Dispose(); LeaveRoom.Dispose(); Trivia.Dispose(); ArrowShot.Dispose(); Shoots.Dispose(); highscore.Dispose(); Menu.Dispose(); bats.Dispose(); Attack.Dispose(); }
public async Task Post([FromBody] LeaveRoom command) { await DispatchAsync(command); }
private void OnLeaveRoom(byte[] data) { string roomName = Encoding.UTF8.GetString(data); LeaveRoom?.Invoke(this, roomName); }