Example #1
0
    void OnLeaveRoomResponse(ResponseBase response)
    {
        RoomAccountList = null;
        RpLeaveRoom leaveRoomResult = response as RpLeaveRoom;

        if (leaveRoomResult.Result)
        {
            CurRoomId = CommonDefine.InvalidRoomId;
            GameMain.Instance.EventMgr.PostObjectEvent(EventId.LeaveRoomSuccess, null);
        }
        else
        {
            GameMain.Instance.EventMgr.PostObjectEvent(EventId.LeaveRoomError, null);
        }
    }
Example #2
0
        public static void OnOperateRequest(MyPeer peer, OperationRequest operationRequest)
        {
            RqLeaveRoom rqEnterRoom = Deserialization(operationRequest.Parameters);

            if (null == rqEnterRoom)
            {
                LBLogger.Info(LogTag, "请求离开Room,解析失败");
                peer.SendCustomEvent(RpId.LeaveRoom, RpLeaveRoom.Serialization(false));
            }
            else
            {
                LBPlayer curPlayer = LBPlayerManager.Instance.GetPlayerByConnectionId(peer.ConnectionId);
                if (null == curPlayer)
                {
                    LBLogger.Info(LogTag, "请求离开Room,当前玩家不存在");
                    peer.SendCustomEvent(RpId.LeaveRoom, RpLeaveRoom.Serialization(false));
                }
                else
                {
                    if (!LBRoomManager.Instance.IsPlayerInRoom(curPlayer.PlayerId))
                    {
                        LBLogger.Info(LogTag, "请求离开房间,但是当前不在房间中 ");
                        peer.SendCustomEvent(RpId.LeaveRoom, RpLeaveRoom.Serialization(false));
                    }
                    else
                    {
                        bool leaveResult = LBRoomManager.Instance.PlayerLeaveRoom(curPlayer.PlayerId);
                        if (leaveResult)
                        {
                            LBLogger.Info(LogTag, "请求离开房间成功");
                            peer.SendCustomEvent(RpId.LeaveRoom, RpLeaveRoom.Serialization(true));
                        }
                        else
                        {
                            LBLogger.Info(LogTag, "请求离开失败");
                            peer.SendCustomEvent(RpId.LeaveRoom, RpLeaveRoom.Serialization(false));
                        }
                    }
                }
            }
        }