コード例 #1
0
        private JoinRoomResponseInfo JoinRoom(long hallRoomId, RoomPlayer roomPlayer)
        {
            var responseInfo = new JoinRoomResponseInfo();

            if (roomPlayer == null)
            {
                responseInfo.ErrCode = ErrorCode.JoinRoom_Message_Error;
            }
            else if (_room == null || _room.IsDiposed)
            {
                responseInfo.ErrCode = ErrorCode.JoinRoom_ServerRoom_Null;
            }
            else
            {
                int errCode    = 0;
                var playerInfo = _room.PlayerJoin(hallRoomId, roomPlayer, out errCode);
                if (playerInfo != null)
                {
                    responseInfo.Success = true;
                    responseInfo.Token   = playerInfo.Token;
                    responseInfo.ErrCode = ErrorCode.None;
                    _playerInfoManager.AddPlayerInfo(playerInfo.Token, playerInfo);

                    _logger.InfoFormat("Player({0}), Id:{1}, Name:{2}, ModelId:{3}, TeamId:{4}, Token:{5}", 0,
                                       roomPlayer.Id, roomPlayer.Name, roomPlayer.RoleModelId, roomPlayer.TeamId, playerInfo.Token);
                }
                else
                {
                    responseInfo.ErrCode = (ErrorCode)errCode;
                }
            }

            responseInfo.PlayerId = roomPlayer != null ? roomPlayer.Id : 0;
            return(responseInfo);
        }
コード例 #2
0
ファイル: ServerRoomEvent.cs プロジェクト: yangfan111/common
 public override void Reset()
 {
     base.Reset();
     HallRoomId           = 0;
     RetCode              = 0;
     JoinRoomResponseInfo = default(JoinRoomResponseInfo);
 }
コード例 #3
0
 private void OnJoinRoom(JoinRoomResponseInfo info)
 {
     if (info.Success && _hasHallServer)
     {
         if (info.Token != null)
         {
             _loginStates[info.Token] = new NetworkState(info.PlayerId);
         }
         else
         {
             _logger.ErrorFormat("The token for player {0} joining room is null", info.PlayerId);
         }
     }
 }