Exemplo n.º 1
0
 /// <summary>
 ///   The log operation response.
 /// </summary>
 /// <param name = "response">
 ///   The response.
 /// </param>
 private static void LogOperationResponse(OperationResponse response)
 {
     foreach (var item in response.Parameters)
     {
         log.DebugFormat(string.Format("{0}({1}): {2}", item.Key, item.Key, item.Value));
     }
 }
Exemplo n.º 2
0
    public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response)
    {
        SubCode subCode = ParameterTool.GetParameter <SubCode>(response.Parameters, ParameterCode.SubCode, false);

        switch (subCode)
        {
        case SubCode.GetTaskDB:
            List <TaskDB> list = ParameterTool.GetParameter <List <TaskDB> >(response.Parameters,
                                                                             ParameterCode.TaskDBList);
            if (OnGetTaskDBList != null)
            {
                OnGetTaskDBList(list);
            }
            break;

        case SubCode.AddTaskDB:
            TaskDB taskDB = ParameterTool.GetParameter <TaskDB>(response.Parameters, ParameterCode.TaskDB);
            if (OnAddTaskDB != null)
            {
                OnAddTaskDB(taskDB);
            }
            break;

        case SubCode.UpdateTaskDB:
            if (OnUpdateTaskDB != null)
            {
                OnUpdateTaskDB();
            }
            break;
        }
    }
Exemplo n.º 3
0
    public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response)
    {
        SubCode subCode = ParameterTool.GetParameters <SubCode>(response.Parameters, ParameterCode.SubCode, false);

        switch (subCode)
        {
        case SubCode.SendTeam:
            if (response.ReturnCode == (short)ReturnCode.GetTeam)
            {
                List <Role> list         = ParameterTool.GetParameters <List <Role> >(response.Parameters, ParameterCode.RoleList);
                int         masterRoleID = ParameterTool.GetParameters <int>(response.Parameters, ParameterCode.MasterRoleID, false);
                //组队成功
                if (OnGetTeam != null)
                {
                    OnGetTeam(list, masterRoleID);
                }
            }
            else if (response.ReturnCode == (short)ReturnCode.WaitTeam)
            {
                if (OnWaitTeam != null)
                {
                    OnWaitTeam();
                }
                //正在组队
            }
            break;

        case SubCode.CancelTeam:
            if (OnCancelTeam != null && response.ReturnCode == (short)ReturnCode.Success)
            {
                OnCancelTeam();
            }
            break;
        }
    }
Exemplo n.º 4
0
    //public void UpdateRole(Role role)
    //{
    //    Dictionary<byte, object> parameters = new Dictionary<byte, object>();
    //    parameters.Add((byte)ParameterCode.Role, JsonMapper.ToJson(role));
    //    PhotonEngine.Instance.SendRequest(OpCode, SubCode.UpdateRole, parameters);
    //}

    public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response)
    {
        SubCode subcode = ParameterTool.GetParameter <SubCode>(response.Parameters, ParameterCode.SubCode, false);

        switch (subcode)
        {
        case SubCode.GetRole:
            List <Role> list = ParameterTool.GetParameter <List <Role> >(response.Parameters, ParameterCode.RoleList);
            OnGetRole(list);
            break;

        case SubCode.AddRole:
            Role role = ParameterTool.GetParameter <Role>(response.Parameters, ParameterCode.Role);
            if (response.ReturnCode == (short)ReturnCode.Fail)
            {
                MessageManager._instance.ShowMessage(response.DebugMessage);
                return;
            }
            OnAddRole(role);
            break;

        case SubCode.SelectRole:
            if (OnSelectRole != null)
            {
                OnSelectRole();
            }
            break;
        }
        if (response.ReturnCode == (short)ReturnCode.Fail)
        {
            MessageManager._instance.ShowMessage(response.DebugMessage);
        }
    }
Exemplo n.º 5
0
        /// <summary>
        ///   The on response received.
        /// </summary>
        /// <param name = "client">
        ///   The client.
        /// </param>
        /// <param name = "response">
        ///   The response.
        /// </param>
        private static void OnResponseReceived(OnlineNUnitClient client, OperationResponse response)
        {
            Action <OnlineNUnitClient, OperationResponse> received = ResponseReceived;

            if (received != null)
            {
                received(client, response);
            }
        }
Exemplo n.º 6
0
    public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response)
    {
        SubCode subCode = ParameterTool.GetParameters <SubCode>(response.Parameters, ParameterCode.SubCode, false);

        //Debug.Log("InventoryItemDB:"+subCode);
        switch (subCode)
        {
        case SubCode.GetInventoryItemDB:
            List <InventoryItemDB> list
                = ParameterTool.GetParameters <List <InventoryItemDB> >(response.Parameters, ParameterCode.InventoryItemdbList);
            //Debug.Log(list);
            if (list == null || list.Count == 0)
            {
                //Debug.Log("数据库没有装备信息");
                return;
            }
            if (OnGetInventoryItemDB != null)
            {
                OnGetInventoryItemDB(list);
            }
            break;

        case SubCode.AddInventoryItemDB:
            InventoryItemDB itemDB = ParameterTool.GetParameters <InventoryItemDB>(response.Parameters, ParameterCode.InventoryItemdb);
            if (OnAddInventoryItemDB != null)
            {
                OnAddInventoryItemDB(itemDB);
            }
            break;

        case SubCode.UpdateInventoryItemDB:
            OnUpdateInventoryItemDB();
            break;

        case SubCode.UpdateInventoryItemDBList:
            if (OnUpdateInventoryItemDBList != null)
            {
                OnUpdateInventoryItemDBList();
            }
            break;

        case  SubCode.GetShopInventoryDBList:
            List <ShopInventoryDB> shoplist
                = ParameterTool.GetParameters <List <ShopInventoryDB> >(response.Parameters, ParameterCode.ShopInventorydbList);
            if (OnGetShopInventoryDB != null)
            {
                OnGetShopInventoryDB(shoplist);
            }
            break;
        }
    }
Exemplo n.º 7
0
        //---------------------------------------------------------------------
        // Interface: IPhotonPeerListener.OnOperationResponse
        public void OnOperationResponse(ExitGames.Client.Photon.OperationResponse operationResponse)
        {
            if (mRpcSession != null)
            {
                Dictionary <byte, object> p = operationResponse.Parameters;
                _tEntityRpcData           data;
                data.rpc_id       = (long)p[0];
                data.from_node    = (byte)p[1];
                data.method_id    = (short)p[2];
                data.map_param    = (Dictionary <byte, object>)p[3];
                data.session_recv = null;

                mRpcSession.recvRpcData(ref data);
            }
        }
Exemplo n.º 8
0
    private void SelectServerUI_OnParseHandler(byte moduleCode, byte opCode, ExitGames.Client.Photon.OperationResponse response)
    {
        //处理获得当前服务器
        HandlerManager.GetInstance().Remove((byte)Module.ServerList, (byte)ServerListOperation.FetchAllServer);
        string json = response.Parameters[(byte)1].ToString();

        //Json序列化成类
        ServerItemVo vo = JsonReader.Deserialize <ServerItemVo>(json);

        //临时存储服务器信息
        Global.GetInstance().mCurrentServerInfo = vo;

        //显示界面
        txtServerTitle.text = (vo.id < 10 ? "0" + vo.id : vo.id + "") + ". " + vo.title;
    }
Exemplo n.º 9
0
    public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response)
    {
        switch (response.ReturnCode)
        {
        case  (short)ReturnCode.Fail:
            MessageManager._instance.ShowMessage(response.DebugMessage, 2);
            break;

        case (short)ReturnCode.Success:
            MessageManager._instance.ShowMessage("注册成功", 2);
            controller.HideRegisterPanel();
            controller.ShowStartPanel();
            controller.usernameLabelStart.text = user.Username;
            break;
        }
    }
Exemplo n.º 10
0
    private void OnLoginResponse(byte moduleCode, byte opCode, ExitGames.Client.Photon.OperationResponse response)
    {
        string json = response.Parameters[1].ToString();

        LoginResultVo vo = JsonReader.Deserialize <LoginResultVo>(json);

        if (vo.result == 1)
        {
            UIManager.GetInstance().SwitchScene("SelectServerUI");
            Global.Info("登录成功!");
        }
        else
        {
            Global.Info("登录失败!");
        }
    }
Exemplo n.º 11
0
    public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response)
    {
        object subobject;

        response.Parameters.TryGetValue((byte)ParameterCode.SubCode, out subobject);
        SubCode subCode = (SubCode)subobject;

        switch (subCode)
        {
        case SubCode.GetRole:
            switch (response.ReturnCode)
            {
            case (short)ReturnCode.Success:
                List <Role> list = ParameterTool.GetParameters <List <Role> >(response.Parameters, ParameterCode.RoleList);
                OnGetRole(list);
                break;

            case (short)ReturnCode.Empty:
                OnGetEmptyRole();        //当服务器没有该角色信息的时候跳转到创建角色的界面。
                break;
            }
            break;

        case SubCode.AddRole:
            switch (response.ReturnCode)
            {
            case (short)ReturnCode.Success:
                Role role = ParameterTool.GetParameters <Role>(response.Parameters, ParameterCode.Role);
                OnAddRole(role);
                break;

            case (short)ReturnCode.Fail:
                //添加角色失败
                MessageManager._instance.SendMessage(response.DebugMessage);
                break;
            }
            break;

        case SubCode.SelectRole:
            if (OnseletRole != null)
            {
                OnseletRole();
            }
            break;
        }
    }
Exemplo n.º 12
0
    public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response)
    {
        MessageManager._instance.ShowMessage(response.DebugMessage);
        switch (response.ReturnCode)
        {
        case (short)ReturnCode.Success:
            StartmenuController.instance.HideLogin();
            StartmenuController.instance.label_start_user.text = user.UserName;
            StartmenuController.instance.ShowStartMenu();
            StartmenuController.instance.isLogin = true;
            break;

        case (short)ReturnCode.Fail:
            StartmenuController.instance.isLogin = false;
            break;
        }
    }
Exemplo n.º 13
0
        public void OnOperationResponse(ExitGames.Client.Photon.OperationResponse operationResponse)
        {
            var response = new OperationResponse
            {
                OperationCode = operationResponse.OperationCode,
                Parameters    = operationResponse.Parameters,
                ReturnCode    = operationResponse.ReturnCode,
                DebugMessage  = operationResponse.DebugMessage,
            };

            if (log.IsDebugEnabled)
            {
                LogOperationResponse(response);
            }

            this.OperationResponseQueue.Enqueue(response);

            OnResponseReceived(this, response);
        }
Exemplo n.º 14
0
        public void OnOperationResponse(OperationResponse operationResponse)
        {
            var response = new OperationResponse
            {
                OperationCode = operationResponse.OperationCode,
                Parameters    = operationResponse.Parameters,
                ReturnCode    = operationResponse.ReturnCode,
                DebugMessage  = operationResponse.DebugMessage,
            };

            if (log.IsDebugEnabled)
            {
                //                LogOperationResponse(response);
                log.DebugFormat("Peer({0}) OperationResponse: {1}",
                                this.Id, Newtonsoft.Json.JsonConvert.SerializeObject(response));
            }

            this.OperationResponseQueue.Enqueue(response);

            OnResponseReceived(this, response);
        }
Exemplo n.º 15
0
    /// <summary>
    /// 从服务器接接到响应
    /// </summary>
    /// <param name="response"></param>
    public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response)
    {
        object subobject;

        response.Parameters.TryGetValue((byte)ParameterCode.SubCode, out subobject);
        SubCode subCode = (SubCode)subobject;

        switch (subCode)
        {
        case SubCode.GetTask:
            List <TaskDB> list = ParameterTool.GetParameters <List <TaskDB> >(response.Parameters, ParameterCode.TaskdbList);
            if (OnGetTaskList != null)
            {
                OnGetTaskList(list);
            }
            break;

        case SubCode.AddTask:
            TaskDB taskDB = ParameterTool.GetParameters <TaskDB>(response.Parameters, ParameterCode.Taskdb);
            if (OnAddTask != null)
            {
                if (response.ReturnCode == (short)ReturnCode.Success)
                {
                    OnAddTask(taskDB);
                }
            }
            break;

        case SubCode.UpdateTask:
            if (OnUpdateTask != null)
            {
                if (response.ReturnCode == (short)ReturnCode.Success)
                {
                    OnUpdateTask();
                }
            }
            break;
        }
    }
Exemplo n.º 16
0
    public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse response)
    {
        SubCode subcode = ParameterTool.GetParameter <SubCode>(response.Parameters, ParameterCode.SubCode, false);

        switch (subcode)
        {
        case SubCode.GetRole:
            List <Role> list = ParameterTool.GetParameter <List <Role> >(response.Parameters, ParameterCode.RoleList);
            OnGetRole(list);
            break;

        case SubCode.AddRole:
            Role role = ParameterTool.GetParameter <Role>(response.Parameters, ParameterCode.Role);
            OnAddRole(role);
            break;

        case SubCode.SelectRole:
            if (OnSelectRole != null)
            {
                OnSelectRole();
            }
            break;
        }
    }
Exemplo n.º 17
0
    private void ServerListUI_OnParseHandler1(byte moduleCode, byte opCode, ExitGames.Client.Photon.OperationResponse response)
    {
        HandlerManager.GetInstance().Remove((byte)Module.ServerList, (byte)ServerListOperation.FetchAllServer);
        //获取服务器返回的信息
        string json = response.Parameters[(byte)1].ToString();

        //转为json
        ServerListVo list = JsonReader.Deserialize <ServerListVo>(json);



        ServerItemUI[] oldSvrs = m_content.GetComponentsInChildren <ServerItemUI>();
        foreach (var item in oldSvrs)
        {
            Destroy(item.gameObject);
        }


        //根据服务器数据生成服务器列表
        foreach (ServerItemVo svr in list.servers)
        {
            ServerItemUI mSvr = UIManager.GetInstance().GetNewUI <ServerItemUI>();
            mSvr.SetServerData(svr);
            mSvr.OnSelectHandler += MSvr_OnSelectHandler;
            mSvr.transform.SetParent(m_content);
        }

        //根据内容调整滚动区域大小
        RectTransform rtf = m_content as RectTransform;

        rtf.sizeDelta = new Vector2(561, Mathf.CeilToInt((float)list.servers.Length / 2) * 90);

        ScrollRect sr = GameObject.FindObjectOfType <ScrollRect>();

        sr.verticalNormalizedPosition = 1;
    }
Exemplo n.º 18
0
 public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse operationResponse)
 {
     base.OnOperationResponse(operationResponse);
 }
Exemplo n.º 19
0
 void IPhotonPeerListener.OnOperationResponse(OperationResponse operationResponse)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 20
0
 public abstract void SerializeOperationResponse(StreamBuffer stream, OperationResponse serObject, bool setType);
Exemplo n.º 21
0
 public override void OnOperationResponse(ExitGames.Client.Photon.OperationResponse operationResponse)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 22
0
        public override OperationRequest DeserializeOperationRequest(StreamBuffer din) => default;         // 0x0000000180A003E0-0x0000000180A00490

        public override void SerializeOperationResponse(StreamBuffer stream, OperationResponse serObject, bool setType)
        {
        }                                                                                                       // 0x0000000180A03F70-0x0000000180A04050
 void IPhotonPeerListener.OnOperationResponse(OperationResponse operationResponse)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 24
0
    private void OnOpResponseActionHandler(ExitGames.Client.Photon.OperationResponse response)
    {
        string operationCode = response.OperationCode.ToString();

        switch (response.OperationCode)
        {
        case OperationCode.Authenticate:
        {
            // did we get errors?
            if (response.ReturnCode != 0)
            {
                // sigh - let the listener know!
                //if (OnConnectError != null) OnConnectError(aOpResponse.ToString());
            }
            operationCode = "OperationCode: Authenciate";
            break;
        }

        case OperationCode.JoinLobby:
        {
            // call our listeners
            //if (OnConnect != null) OnConnect();
            operationCode = "OperationCode: JoinLobby";
            break;
        }

        case OperationCode.JoinRandomGame:
        {
            // did we find a game?
            if (response.ReturnCode != 0)
            {
                // sigh - let the listener know!
                if (OnFindGame != null)
                {
                    OnFindGame(false);
                }
            }
            else
            {
                // yaay!
                if (OnFindGame != null)
                {
                    OnFindGame(true);
                }
            }

            operationCode = "OperationCode: JoinRandomGame";
            break;
        }

        case OperationCode.SetProperties:
        {
            // dump room info
            operationCode = "OperationCode: SetProperties";
            var playerList = _loadBalancingClient.CurrentRoom.Players;
            //Log.Debug("PHOTON: PLAYER: ROOMINFO: Players =>\n{0}", JsonConvert.SerializeObject(playerList));
            break;
        }

        case OperationCode.GetGameList:
        {
            ShowRoomInfoData();
            break;
        }

        default: break;
        }

        if (OnOpResponseAction != null)
        {
            OnOpResponseAction(operationCode);
        }
        //_lobbyInfo.text = operationCode;
    }
Exemplo n.º 25
0
        internal virtual bool DeserializeMessageAndCallback(byte[] inBuff)
        {
            bool flag = inBuff.Length < 2;
            bool result;

            if (flag)
            {
                bool flag2 = this.debugOut >= DebugLevel.ERROR;
                if (flag2)
                {
                    this.Listener.DebugReturn(DebugLevel.ERROR, "Incoming UDP data too short! " + inBuff.Length);
                }
                result = false;
            }
            else
            {
                bool flag3 = inBuff[0] != 243 && inBuff[0] != 253;
                if (flag3)
                {
                    bool flag4 = this.debugOut >= DebugLevel.ERROR;
                    if (flag4)
                    {
                        this.Listener.DebugReturn(DebugLevel.ALL, "No regular operation UDP message: " + inBuff[0]);
                    }
                    result = false;
                }
                else
                {
                    byte         b            = inBuff[1] & 127;
                    bool         flag5        = (inBuff[1] & 128) > 0;
                    StreamBuffer streamBuffer = null;
                    bool         flag6        = b != 1;
                    if (flag6)
                    {
                        try
                        {
                            bool flag7 = flag5;
                            if (flag7)
                            {
                                inBuff       = this.CryptoProvider.Decrypt(inBuff, 2, inBuff.Length - 2);
                                streamBuffer = new StreamBuffer(inBuff);
                            }
                            else
                            {
                                streamBuffer = new StreamBuffer(inBuff);
                                streamBuffer.Seek(2L, SeekOrigin.Begin);
                            }
                        }
                        catch (Exception ex)
                        {
                            bool flag8 = this.debugOut >= DebugLevel.ERROR;
                            if (flag8)
                            {
                                this.Listener.DebugReturn(DebugLevel.ERROR, ex.ToString());
                            }
                            SupportClass.WriteStackTrace(ex);
                            result = false;
                            return(result);
                        }
                    }
                    int num = 0;
                    switch (b)
                    {
                    case 1:
                        this.InitCallback();
                        goto IL_360;

                    case 3:
                    {
                        OperationResponse operationResponse = this.protocol.DeserializeOperationResponse(streamBuffer);
                        bool trafficStatsEnabled            = this.TrafficStatsEnabled;
                        if (trafficStatsEnabled)
                        {
                            this.TrafficStatsGameLevel.CountResult(this.ByteCountCurrentDispatch);
                            num = SupportClass.GetTickCount();
                        }
                        this.Listener.OnOperationResponse(operationResponse);
                        bool trafficStatsEnabled2 = this.TrafficStatsEnabled;
                        if (trafficStatsEnabled2)
                        {
                            this.TrafficStatsGameLevel.TimeForResponseCallback(operationResponse.OperationCode, SupportClass.GetTickCount() - num);
                        }
                        goto IL_360;
                    }

                    case 4:
                    {
                        EventData eventData            = this.protocol.DeserializeEventData(streamBuffer);
                        bool      trafficStatsEnabled3 = this.TrafficStatsEnabled;
                        if (trafficStatsEnabled3)
                        {
                            this.TrafficStatsGameLevel.CountEvent(this.ByteCountCurrentDispatch);
                            num = SupportClass.GetTickCount();
                        }
                        this.Listener.OnEvent(eventData);
                        bool trafficStatsEnabled4 = this.TrafficStatsEnabled;
                        if (trafficStatsEnabled4)
                        {
                            this.TrafficStatsGameLevel.TimeForEventCallback(eventData.Code, SupportClass.GetTickCount() - num);
                        }
                        goto IL_360;
                    }

                    case 7:
                    {
                        OperationResponse operationResponse = this.protocol.DeserializeOperationResponse(streamBuffer);
                        bool trafficStatsEnabled5           = this.TrafficStatsEnabled;
                        if (trafficStatsEnabled5)
                        {
                            this.TrafficStatsGameLevel.CountResult(this.ByteCountCurrentDispatch);
                            num = SupportClass.GetTickCount();
                        }
                        bool flag9 = operationResponse.OperationCode == PhotonCodes.InitEncryption;
                        if (flag9)
                        {
                            this.DeriveSharedKey(operationResponse);
                        }
                        else
                        {
                            bool flag10 = operationResponse.OperationCode == PhotonCodes.Ping;
                            if (flag10)
                            {
                                TPeer tPeer  = this as TPeer;
                                bool  flag11 = tPeer != null;
                                if (flag11)
                                {
                                    tPeer.ReadPingResult(operationResponse);
                                }
                                else
                                {
                                    this.EnqueueDebugReturn(DebugLevel.ERROR, "Ping response not used. " + operationResponse.ToStringFull());
                                }
                            }
                            else
                            {
                                this.EnqueueDebugReturn(DebugLevel.ERROR, "Received unknown internal operation. " + operationResponse.ToStringFull());
                            }
                        }
                        bool trafficStatsEnabled6 = this.TrafficStatsEnabled;
                        if (trafficStatsEnabled6)
                        {
                            this.TrafficStatsGameLevel.TimeForResponseCallback(operationResponse.OperationCode, SupportClass.GetTickCount() - num);
                        }
                        goto IL_360;
                    }
                    }
                    this.EnqueueDebugReturn(DebugLevel.ERROR, "unexpected msgType " + b);
IL_360:
                    result = true;
                }
            }
            return(result);
        }