Beispiel #1
0
    /// <summary>
    /// 创建房间响应
    /// </summary>
    /// <param name="bytes"></param>
    private void CreateRoomResponse(byte[] bytes)
    {
        CheckCreateRoomS2C package = NetMgr.Instance.DeSerializes <CheckCreateRoomS2C>(bytes);

        if (package.clientCode == (int)ErrorCode.SUCCESS)
        {
            this.HallInfo.battleSeverIP   = package.roomServerIp;
            this.HallInfo.battleSeverPort = package.roomServerPort;
            this.HallInfo.roomCode        = package.roomCode;
            this.HallInfo.seat            = package.seat;
            NSocket.UpdateRoomID(HallInfo.roomCode == "" ? 0 : int.Parse(HallInfo.roomCode));
            this.BattleServerConnect(NotificationConstant.MEDI_HALL_CUTCREATESCENE);
        }
        else
        {
            DialogMsgVO dialogVO = new DialogMsgVO();
            dialogVO.dialogType = DialogType.ALERT;
            dialogVO.title      = "创建房间失败";
            if (package.clientCode == 3)
            {
                dialogVO.content = "最多可创建5个房间!";
            }
            else
            {
                dialogVO.content = "创建房间失败,请检查网络连接";
            }
            DialogView dialogView = UIManager.Instance.ShowUI(UIViewID.DIALOG_VIEW) as DialogView;
            dialogView.data = dialogVO;
        }
    }
Beispiel #2
0
 void Awake()
 {
     NetMgr.Instance.StopAllTcpConnection();
     Debug.Log("断开所有与服务器连接");
     NSocket.UpdateUserID(0);
     NSocket.UpdateRoomID(0);
     ApplicationFacade.Instance.RegisterMediator(new LoginMgrMediator(Mediators.LOGIN_MGR_MEDIATOR, this));
     if (Application.isMobilePlatform)
     {
         ApplicationFacade.Instance.SendNotification(NotificationConstant.COMM_CHECK_VERSION);
     }
 }
Beispiel #3
0
    /// <summary>
    /// 断线重连
    /// </summary>
    /// <param name="bytes"></param>
    private void ReConnectHandler(byte[] bytes)
    {
        ReConnectS2C reconnectS2C = NetMgr.Instance.DeSerializes <ReConnectS2C>(bytes);

        this.HallInfo.roomCode        = reconnectS2C.roomCode;
        this.HallInfo.battleSeverIP   = reconnectS2C.roomIp;
        this.HallInfo.battleSeverPort = reconnectS2C.roomPort;
        NSocket.UpdateRoomID(reconnectS2C.roomCode == "" ? 0 : int.Parse(reconnectS2C.roomCode));
        if (reconnectS2C.roomId > 0)
        {
            this.BattleServerConnect(NotificationConstant.MEDI_HALL_CUTJOINSCENE);
        }
        else
        {
            SendNotification(NotificationConstant.MEDI_LOGIN_SWITCHHALLSCENE);
        }
    }
Beispiel #4
0
    /// <summary>
    /// 加入房间响应
    /// </summary>
    /// <param name="bytes"></param>
    private void JoinRoomResponse(byte[] bytes)
    {
        JoinInRoomS2C package = NetMgr.Instance.DeSerializes <JoinInRoomS2C>(bytes);

        if (package.clientCode == (int)ErrorCode.SUCCESS)
        {
            this.HallInfo.innings         = (GameMode)package.roomRounds;
            this.HallInfo.gameRule        = (GameRule)package.roomRule;
            this.HallInfo.battleSeverIP   = package.roomServerIp;
            this.HallInfo.battleSeverPort = package.roomServerPort;
            this.HallInfo.seat            = package.seat;
            NSocket.UpdateRoomID(HallInfo.roomCode == "" ? 0 : int.Parse(HallInfo.roomCode));
            this.BattleServerConnect(NotificationConstant.MEDI_HALL_CUTJOINSCENE);
        }
        else if (package.clientCode == (int)ErrorCode.NO_ROOM)
        {
            DialogMsgVO dialogVO = new DialogMsgVO();
            dialogVO.dialogType = DialogType.ALERT;
            dialogVO.title      = "加入提示";
            dialogVO.content    = "房间不存在";
            DialogView dialogView = UIManager.Instance.ShowUI(UIViewID.DIALOG_VIEW) as DialogView;
            dialogView.data = dialogVO;
        }
        else if (package.clientCode == (int)ErrorCode.OVERFLOW_ROOM_PLAYERS)
        {
            DialogMsgVO dialogVO = new DialogMsgVO();
            dialogVO.dialogType = DialogType.ALERT;
            dialogVO.title      = "加入提示";
            dialogVO.content    = "房间人数已满!";
            DialogView dialogView = UIManager.Instance.ShowUI(UIViewID.DIALOG_VIEW) as DialogView;
            dialogView.data = dialogVO;
        }
        else
        {
            DialogMsgVO dialogVO = new DialogMsgVO();
            dialogVO.dialogType = DialogType.ALERT;
            dialogVO.title      = "加入房间失败";
            dialogVO.content    = "加入房间失败,请检查网络连接";
            DialogView dialogView = UIManager.Instance.ShowUI(UIViewID.DIALOG_VIEW) as DialogView;
            dialogView.data = dialogVO;
        }
    }