Esempio n. 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);
        }