• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# OperationResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中OperationResponse的典型用法代码示例。如果您正苦于以下问题:C# OperationResponse类的具体用法?C# OperationResponse怎么用?C# OperationResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OperationResponse类属于命名空间,在下文中一共展示了OperationResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnHandleResponse

    public override void OnHandleResponse(OperationResponse response)
    {
        NetworkManager view = _controller.ControlledView as NetworkManager;
        if (response.ReturnCode == 0)
        {
            // TODO FIX THIS FOR ONLY 1 PLANET??
            view.LogDebug(response.Parameters[(byte)ClientParameterCode.Planets].ToString());
            DisplayManager.Instance.DisplayMessage("Planet Colonized!");

            // Deserialize
            var xmlData = response.Parameters[(byte)ClientParameterCode.Planets].ToString();
            XmlSerializer deserializer = new XmlSerializer(typeof(XmlPlanetList));
            TextReader reader = new StringReader(xmlData);
            object obj = deserializer.Deserialize(reader);
            XmlPlanetList planetCollection = (XmlPlanetList)obj;
            reader.Close();

            // Update local data
            foreach (SanPlanet p in planetCollection.Planets)
                PlayerData.instance.AddOwnedPlanet(new OwnedPlanet(p));
        }
        else
        {
            view.LogDebug("RESPONSE: " + response.DebugMessage);
            DisplayManager.Instance.DisplayMessage(response.DebugMessage);
        }
    }
开发者ID:seanbraley,项目名称:PocketCosmos,代码行数:27,代码来源:ColonizePlanetResponseHandler.cs


示例2: OnOperationRequest

        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("OnOperationRequest. Code={0}", operationRequest.OperationCode);
            }

            switch (operationRequest.OperationCode)
            {
                case (byte)MyOperationCodes.EchoOperation:
                    {
                        // The echo operation one is handled immediately because it does not require the client to join a game.
                        var myEchoRequest = new MyEchoRequest(this.Protocol, operationRequest);
                        if (this.ValidateOperation(myEchoRequest, sendParameters) == false)
                        {
                            return;
                        }

                        var myEchoResponse = new MyEchoResponse { Response = myEchoRequest.Text };
                        var operationResponse = new OperationResponse(operationRequest.OperationCode, myEchoResponse);
                        this.SendOperationResponse(operationResponse, sendParameters);
                        break;
                    }

                default:
                    {
                        // for this example all other operations will handled by the base class
                        base.OnOperationRequest(operationRequest, sendParameters);
                        return;
                    }
            }
        }
开发者ID:ommziSolution,项目名称:PhotonServer,代码行数:32,代码来源:MyPeer.cs


示例3: OnOperationReturn

        public override void OnOperationReturn(ClientConnection client, OperationResponse operationResponse)
        {
            Counters.ReceivedOperationResponse.Increment();
            WindowsCounters.ReceivedOperationResponse.Increment();

            switch (operationResponse.OperationCode)
            {
                case (byte)LoadBalancingEnums.OperationCode.Authenticate:
                    if (operationResponse.ReturnCode == 0)
                    {
                       client.AuthenticationTicket = (string)operationResponse[(byte)LoadBalancingEnums.ParameterCode.Secret];
                       this.TransitState(client);
                    }
                    else
                    {
                        log.WarnFormat("OnOperationReturn: Authenticate on Master failed: ReturnCode: {0} ({1}). Disconnecting...", operationResponse.ReturnCode, operationResponse.DebugMessage);
                        client.Peer.Disconnect();
                    }
                    break;

                default:
                    {
                        log.WarnFormat("OnOperationReturn: unexpected return code {0} of operation {1}", operationResponse.ReturnCode, operationResponse.OperationCode);
                        break;
                    }
            }
        }
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:27,代码来源:ConnectedToMaster.cs


示例4: OnHandlerMessage

        public override void OnHandlerMessage(Photon.SocketServer.OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters)
        {
            SubCode subCode = ParameterTool.GetParameter<SubCode>(request.Parameters,ParameterCode.SubCode,false);
            //给response参数添加subCode
            response.Parameters.Add((byte) ParameterCode.SubCode,subCode);

            switch (subCode)
            {
                case SubCode.AddTaskDB:
                    TaskDB taskDB = ParameterTool.GetParameter<TaskDB>(request.Parameters, ParameterCode.TaskDB);
                    taskDB.Role = peer.LoginRole;
                    taskDBManager.AddTaskDB(taskDB);
                    taskDB.Role = null;
                    ParameterTool.AddParameter(response.Parameters,ParameterCode.TaskDB, taskDB);
                    response.ReturnCode = (short) ReturnCode.Success;
                    break;
                case SubCode.GetTaskDB:
                    List<TaskDB> list = taskDBManager.GetTaskDBList(peer.LoginRole);
                    foreach (var taskDb in list)
                    {
                        taskDb.Role = null;
                    }
                    ParameterTool.AddParameter(response.Parameters,ParameterCode.TaskDBList, list);
                    response.ReturnCode = (short) ReturnCode.Success;
                    break;
                case SubCode.UpdateTaskDB:
                    TaskDB taskDB2 = ParameterTool.GetParameter<TaskDB>(request.Parameters, ParameterCode.TaskDB);
                    taskDB2.Role = peer.LoginRole;
                    taskDBManager.UpdataTaskDB(taskDB2);
                    response.ReturnCode = (short) ReturnCode.Success;
                    break;
            }
        }
开发者ID:vin120,项目名称:TaiDouServer,代码行数:33,代码来源:TaskDBHandler.cs


示例5: OnHandlerMeesage

        public override OperationResponse OnHandlerMeesage(OperationRequest request, ClientPeer peer)
        {
            //1.获得客户端发送的帐号和明文密码
            object json;
            request.Parameters.TryGetValue((byte) ParameterCode.UserCheckInfo, out json);
            var user = JsonMapper.ToObject<User>(json.ToString());
            var userDb = _manager.GetUserByUsername(user.Username);
            var s = userDb != null
                ? string.Format("user.Username:{0},user.Password:{1} userDb.Username:{2},userDb.Password:{3}",
                    user.Username, user.Password, userDb.Username, userDb.Password)
                : "未找到用户:" + user.Username;
            peer.WriteLog(s);

            //2.比较,然后创建响应
            var response = new OperationResponse {OperationCode = request.OperationCode};
            if (userDb != null && userDb.Password == MD5Tool.GetMD5(user.Password))
            {
                response.ReturnCode = (short) ReturnCode.Success;
                peer.SetUser(userDb);
            }
            else
            {
                response.ReturnCode = (short) ReturnCode.Fail;
                response.DebugMessage = "用户名或密码错误!";
            }

            return response;
        }
开发者ID:XmingBunny,项目名称:ARPGPhotonServer,代码行数:28,代码来源:LoginHandler.cs


示例6: OnOperationReturn

        public override void OnOperationReturn(ClientConnection client, OperationResponse operationResponse)
        {
            Counters.ReceivedOperationResponse.Increment();
            WindowsCounters.ReceivedOperationResponse.Increment();

            switch (operationResponse.OperationCode)
            {
                case OperationCode.JoinGame:
                    {
                        if (operationResponse.ReturnCode == 0)
                        {
                            this.TransitState(client);
                        }
                        else
                        {
                            log.WarnFormat("OnOperationReturn: unexpected return code {0} of operation {1}", operationResponse.ReturnCode, operationResponse.OperationCode);
                            client.Stop();
                        }

                        break;
                    }

                default:
                    {
                        log.WarnFormat("OnOperationReturn: unexpected return code {0} of operation {1}", operationResponse.ReturnCode, operationResponse.OperationCode);
                        break;
                    }
            }
        }
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:29,代码来源:Connected.cs


示例7: OnOperationRequest

        protected override void OnOperationRequest(OperationRequest request, SendParameters sendParameters)
        {
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("OnOperationRequest: pid={0}, op={1}", this.ConnectionId, request.OperationCode);
            }

            switch ((OperationCode)request.OperationCode)
            {
                default:
                    var response = new OperationResponse(request.OperationCode) { ReturnCode = (short)ErrorCode.OperationInvalid, DebugMessage = "Unknown operation code" };
                    this.SendOperationResponse(response, sendParameters);
                    break;

                case OperationCode.Authenticate:
                    OperationResponse authenticateResponse = this.HandleAuthenticate(request);
                    this.SendOperationResponse(authenticateResponse, sendParameters);
                    break;

                case OperationCode.CreateGame:
                case OperationCode.JoinLobby:
                case OperationCode.LeaveLobby:
                case OperationCode.JoinRandomGame:
                case OperationCode.JoinGame:
                    this.lobby.EnqueueOperation(this, request, sendParameters);
                    break;
            }
        }
开发者ID:azanium,项目名称:PopBloop-GameServer,代码行数:28,代码来源:MasterClientPeer.cs


示例8: DiscardItemResponseTask

 private void DiscardItemResponseTask(OperationResponse operationResponse)
 {
     try
     {
         if (operationResponse.ReturnCode == (short)ErrorType.Correct)
         {
             ItemID itemID = (ItemID)operationResponse.Parameters[(byte)DiscardItemResponseItem.ItemID];
             int itemCount = (int)operationResponse.Parameters[(byte)DiscardItemResponseItem.ItemCount];
             if(OnDiscardItemResponse != null)
                 OnDiscardItemResponse(true, itemID, itemCount);
         }
         else
         {
             if (OnAlert != null)
                 OnAlert(operationResponse.DebugMessage);
             if (OnDiscardItemResponse != null)
                 OnDiscardItemResponse(false, 0, 0);
         }
     }
     catch (Exception ex)
     {
         DebugReturn(DebugLevel.ERROR, ex.Message);
         DebugReturn(DebugLevel.ERROR, ex.StackTrace);
     }
 }
开发者ID:DSobscure,项目名称:Resource-Emperor,代码行数:25,代码来源:PhotonServiceOperationResponseTasks.cs


示例9: ExploreResponseTask

 private void ExploreResponseTask(OperationResponse operationResponse)
 {
     try
     {
         if (operationResponse.ReturnCode == (short)ErrorType.Correct)
         {
             List<int> pathIDs = JsonConvert.DeserializeObject<List<int>>((string)operationResponse.Parameters[(byte)ExploreResponseItem.DiscoveredPathIDsDataString]);
             List<Pathway> paths = new List<Pathway>();
             foreach (int pathID in pathIDs)
             {
                 if (GameGlobal.GlobalMap.paths.ContainsKey(pathID))
                 {
                     paths.Add(GameGlobal.GlobalMap.paths[pathID]);
                 }
             }
             if (OnExploreResponse != null)
                 OnExploreResponse(true, paths);
         }
         else
         {
             if (OnAlert != null)
                 OnAlert(operationResponse.DebugMessage);
             if (OnExploreResponse != null)
                 OnExploreResponse(false, null);
         }
     }
     catch (Exception ex)
     {
         DebugReturn(DebugLevel.ERROR, ex.Message);
         DebugReturn(DebugLevel.ERROR, ex.StackTrace);
     }
 }
开发者ID:DSobscure,项目名称:Resource-Emperor,代码行数:32,代码来源:PhotonServiceOperationResponseTasks.cs


示例10: OnOperationResponse

    public void OnOperationResponse(OperationResponse operationResponse)
    {
        // display operationCode
        this.DebugReturn(0, string.Format("OperationResult:" +
        operationResponse.OperationCode.ToString()));
        switch (operationResponse.OperationCode)
        {
            case (byte)OperationCode.Login:
                {
                    if (operationResponse.ReturnCode == (short)ErrorCode.Ok) // if success
                    {
                        getRet = Convert.ToInt32(operationResponse.Parameters[(byte)LoginResponseCode.Ret]);
                        getMemberID = Convert.ToString(operationResponse.Parameters[(byte)LoginResponseCode.MemberID]);
                        getMemberPW = Convert.ToString(operationResponse.Parameters[(byte)LoginResponseCode.MemberPW]);
                        getNickname = Convert.ToString(operationResponse.Parameters[(byte)LoginResponseCode.Nickname]);
                        LoginStatus = true;

                    }
                    else
                    {
                        LoginResult = operationResponse.DebugMessage;
                        LoginStatus = false;
                    }
                    break;
                }
        }
        //throw new System.NotImplementedException();
    }
开发者ID:joeytsao,项目名称:Pho_JI,代码行数:28,代码来源:PhotonScript.cs


示例11: OnOperationResponse

	public override void OnOperationResponse (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;
		}
	}
开发者ID:xiaopan1991,项目名称:TaidouARPGProject,代码行数:27,代码来源:TaskDBController.cs


示例12: OnHandlerMeesage

        public override OperationResponse OnHandlerMeesage(OperationRequest request, ClientPeer peer)
        {
            object json;
            request.Parameters.TryGetValue((byte) ParameterCode.UserCheckInfo, out json);
            var user = JsonMapper.ToObject<User>(json.ToString());
            var response = new OperationResponse {OperationCode = request.OperationCode};

            //查询数据库
            var userDb = _manager.GetUserByUsername(user.Username);
            if (userDb == null)
            {
                if (_manager.RegisterUser(user))
                {
                    response.ReturnCode = (short) ReturnCode.Success;
                    peer.SetUser(user);
                }
                else
                {
                    response.ReturnCode = (short) ReturnCode.Eception;
                    response.DebugMessage = "异常";
                }
            }
            else
            {
                response.ReturnCode = (short) ReturnCode.Fail;
                response.DebugMessage = "用户名已存在!";
            }
            return response;
        }
开发者ID:XmingBunny,项目名称:ARPGPhotonServer,代码行数:29,代码来源:RegisterHandler.cs


示例13: OnHandleResponse

    public override void OnHandleResponse(OperationResponse response)
    {
        NetworkManager view = _controller.ControlledView as NetworkManager;
        view.LogDebug("GOT A RESPONSE for KNOWN Planets");
        if (response.ReturnCode == 0)
        {
            // TODO FIX THIS FOR ONLY 1 PLANET??
            view.LogDebug(response.Parameters[(byte)ClientParameterCode.Planets].ToString());

            // Deserialize
            var xmlData = response.Parameters[(byte)ClientParameterCode.Planets].ToString();
            XmlSerializer deserializer = new XmlSerializer(typeof(XmlPlanetList));
            TextReader reader = new StringReader(xmlData);
            object obj = deserializer.Deserialize(reader);
            XmlPlanetList planetCollection = (XmlPlanetList)obj;
            reader.Close();

            // Update local data
            foreach (SanPlanet p in planetCollection.Planets) {
                var planet = PlayerData.instance.ownedPlanets.Find(x => x.starID == p.StarId && x.planetID == p.PlanetNum);
                if (planet != null)
                {
                    planet.planetpopulation = p.Population;
                }
            }              
                


        }
        else
        {
            view.LogDebug("RESPONSE: " + response.DebugMessage);
            DisplayManager.Instance.DisplayMessage(response.DebugMessage);
        }
    }
开发者ID:seanbraley,项目名称:PocketCosmos,代码行数:35,代码来源:UpdatePopulationResponseHandler.cs


示例14: WorldEnterEventArgs

 /// <summary>
 /// 类型:方法
 /// 名称:EnterWorldEventArgs
 /// 作者:taixihuase
 /// 作用:用自身角色进入场景所感兴趣的数据构造事件数据
 /// 编写日期:2015/7/22
 /// </summary>
 /// <param name="response"></param>
 public WorldEnterEventArgs(OperationResponse response)
 {
     Position position = (Position)
         Serialization.Deserialize(response.Parameters[(byte) ParameterCode.WorldEnter]);
     MyCharacterPosition = position;
     AnyCharacter = null;
 }
开发者ID:taixihuase,项目名称:SiegeOnline,代码行数:15,代码来源:WorldEnterEventArgs.cs


示例15: GetResponse

 public virtual OperationResponse GetResponse(ErrorCode errorCode, string debugMessage = "")
 {
     var response = new OperationResponse(OperationRequest.OperationCode);
     response.ReturnCode = (short) errorCode;
     response.DebugMessage = debugMessage;
     return response;
 }
开发者ID:nPaul,项目名称:TestPhotonLib,代码行数:7,代码来源:BaseOperation.cs


示例16: OnHandleResponse

 public override void OnHandleResponse(OperationResponse response)
 {
     if (response.ReturnCode == 0)
     {
         Application.LoadLevel("CharacterLoading");
     }
 }
开发者ID:adowning,项目名称:ComplexServer,代码行数:7,代码来源:SelectCharacterHandler.cs


示例17: OnOperationReturn

        public override void OnOperationReturn(ClientConnection client, OperationResponse operationResponse)
        {
            Counters.ReceivedOperationResponse.Increment();
            WindowsCounters.ReceivedOperationResponse.Increment();

            switch (operationResponse.OperationCode)
            {
                case (byte)LoadBalancingEnums.OperationCode.JoinGame:
                case (byte)LoadBalancingEnums.OperationCode.CreateGame:
                    if (operationResponse.ReturnCode == 0)
                    {
                        this.TransitState(client);
                    }
                    else
                    {
                        log.WarnFormat("OnOperationReturn: {0} failed: ReturnCode: {1} ({2}). Disconnecting...", Enum.GetName(typeof(LoadBalancingEnums.OperationCode), operationResponse.OperationCode), operationResponse.ReturnCode, operationResponse.DebugMessage);
                        client.Peer.Disconnect();
                    }
                    break;

                default:
                    {
                        log.WarnFormat("OnOperationReturn: unexpected return code {0} of operation {1}", operationResponse.ReturnCode, operationResponse.OperationCode);
                        break;
                    }
            }
        }
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:27,代码来源:AuthenticatedOnGameServer.cs


示例18: OnOperationRequest

        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            switch (operationRequest.OperationCode)
            {
                default:
                    {
                        string message = string.Format("Unknown operation code {0}", operationRequest.OperationCode);
                        this.SendOperationResponse(new OperationResponse { OperationCode = operationRequest.OperationCode, ReturnCode = -1, DebugMessage = message }, sendParameters);
                        break;
                    }

                case 1:
                    {
                        var pingOperation = new LatencyOperation(this.Protocol, operationRequest.Parameters);
                        if (pingOperation.IsValid == false)
                        {
                            this.SendOperationResponse(new OperationResponse { OperationCode = operationRequest.OperationCode, ReturnCode = -1, DebugMessage = pingOperation.GetErrorMessage() }, sendParameters);
                            return;
                        }

                        Thread.Sleep(5);

                        var response = new OperationResponse(operationRequest.OperationCode, pingOperation);
                        this.SendOperationResponse(response, sendParameters);
                        break;
                    }
            }
        }
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:28,代码来源:LatencyPeer.cs


示例19: OnHandleResponse

    public override void OnHandleResponse(OperationResponse response)
    {

        NetworkManager view = _controller.ControlledView as NetworkManager;
        view.LogDebug("GOT A RESPONSE for KNOWN STARS");
        if (response.ReturnCode == 0)
        {
            view.LogDebug(response.Parameters[(byte)ClientParameterCode.KnownStars].ToString());

            // Deserialize
            var xmlData = response.Parameters[(byte)ClientParameterCode.KnownStars].ToString();
            XmlSerializer deserializer = new XmlSerializer(typeof(XmlStarPlayerList));
            TextReader reader = new StringReader(xmlData);
            object obj = deserializer.Deserialize(reader);
            XmlStarPlayerList starCollection = (XmlStarPlayerList)obj;
            reader.Close();

            List<KnownStar> stars = new List<KnownStar>();
            foreach (SanStarPlayer s in starCollection.StarPlayers)
                stars.Add(new KnownStar(s));

            // Update local data
            PlayerData.instance.UpdateKnownStars(stars);
        }
        else
        {
            view.LogDebug("RESPONSE: " + response.DebugMessage);
            DisplayManager.Instance.DisplayMessage(response.DebugMessage);
        }
    }
开发者ID:seanbraley,项目名称:PocketCosmos,代码行数:30,代码来源:KnownStarsResponseHandler.cs


示例20: OnHandleResponse

    public override void OnHandleResponse(OperationResponse response)
    {

        //NetworkManager view = _controller.ControlledView as NetworkManager;
        NetworkManager view = _controller.ControlledView as NetworkManager;
        view.LogDebug("GOT A RESPONSE for PROFILE");
        if (response.ReturnCode == 0)
        {
            view.LogDebug(response.Parameters[(byte)ClientParameterCode.Spacebux].ToString());
            view.LogDebug(response.Parameters[(byte)ClientParameterCode.Homestar].ToString());
            view.LogDebug(response.Parameters[(byte)ClientParameterCode.LastLocX].ToString());
            view.LogDebug(response.Parameters[(byte)ClientParameterCode.LastLocY].ToString());

            // Update local player data according to server
            PlayerData.instance.UpdateLocalData(
                (int)response.Parameters[(byte)ClientParameterCode.Spacebux], 
                (long)response.Parameters[(byte)ClientParameterCode.Homestar],
                (int)response.Parameters[(byte)ClientParameterCode.LastLocX],
                (int)response.Parameters[(byte)ClientParameterCode.LastLocY]
                );
           
        }
        else
        {
            view.LogDebug("RESPONSE: " + response.DebugMessage);
            DisplayManager.Instance.DisplayMessage(response.DebugMessage);
        }
    }
开发者ID:seanbraley,项目名称:PocketCosmos,代码行数:28,代码来源:PlayerProfileResponseHandler.cs



注:本文中的OperationResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# OperationResult类代码示例发布时间:2022-05-24
下一篇:
C# OperationRequest类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap