当前位置: 首页>>代码示例>>C#>>正文


C# IProtocol.GetSubProtocol方法代码示例

本文整理汇总了C#中IProtocol.GetSubProtocol方法的典型用法代码示例。如果您正苦于以下问题:C# IProtocol.GetSubProtocol方法的具体用法?C# IProtocol.GetSubProtocol怎么用?C# IProtocol.GetSubProtocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IProtocol的用法示例。


在下文中一共展示了IProtocol.GetSubProtocol方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MessageReceived

		private void MessageReceived(GameServer server, IProtocol message)
        {
            ISubProtocol pSubProtocol = message.GetSubProtocol();
            if (pSubProtocol == null ||
                (ProtocolDef)message.ProtocolId != ProtocolDef.l2e_header_def)
            {
                return;
            }
            byte[] data = message.ToBytes();
            switch ((ProtocolDef)pSubProtocol.SubProtocolID)
            {
                // ahpho
                case ProtocolDef.l2e_update_custom_info_def:
                    {
                        l2e_update_custom_info protocal = new l2e_update_custom_info();
                        protocal.FromBytes(data);
                        _customInfoStrs = protocal.GetInfoStrs();
                    }
                    break;
                case ProtocolDef.l2e_PlayerCount_def:
                    {
                        l2e_PlayerCount protocol = new l2e_PlayerCount();
                        protocol.FromBytes(data);
                        if (protocol.GetTotalCount() >= 0)
                        {
                            UpdatePlayerCount(protocol.GetTotalCount(),server.Group);                            
                        }

                        if (protocol.GetOffliveCount() >= 0)
                            UpdateOfflineCount(protocol.GetOffliveCount());
                    }
                    break;
                
                //GM指令接收的消息
                case ProtocolDef.l2e_ExeGMCmd_def:
                    {
                        l2e_ExeGMCmd protocol = new l2e_ExeGMCmd();
                        protocol.FromBytes(data);
                        //l2e_ExeGMCmd protocol = (l2e_ExeGMCmd)message;
                        if (protocol.ReturnCode == 1)
                        {
                            UpdateGMResultCache(protocol.nSessionID, protocol.szResult);
                        }
                        else
                        {
                            UpdateGMResultCache(protocol.nSessionID, "GM指令操作失败");
                        }                          
                    }
                    break;
                case ProtocolDef.l2e_GetBasicInfo_def:
                    {
                        l2e_GetBasicInfo protocol = new l2e_GetBasicInfo();
                        protocol.FromBytes(data);
                    }
                    break;
                case ProtocolDef.l2e_Who_def:
                    {
                        l2e_Who protocol = new l2e_Who();
                        protocol.FromBytes(data);
                        UpdatePlayerWho(protocol.PlayerList);
                    }
                    break;
                case ProtocolDef.l2e_GetGlobalVariable_def:
                    {
                        l2e_GetGlobalVariable protocol = new l2e_GetGlobalVariable();
                        protocol.FromBytes(data);
                        server.GameSetting.UpdateGlobalVariable(protocol.VariableIndex, protocol.VariableValue);
                    }
                    break;
                case ProtocolDef.l2e_GetGameStartTime_def:
                    {
                        l2e_GetGameStartTime protocol = new l2e_GetGameStartTime();
                        protocol.FromBytes(data);
                        int seconds = int.Parse(protocol.GameStartTime);
                        _gameRunningRefreshTime = DateTime.Now;
                        _gameRunningTime = new TimeSpan(0, 0, seconds);
                    }
                    break;
                case ProtocolDef.l2e_ReportError_def:
                    {
                        l2e_ReportError protocol = new l2e_ReportError();
                        protocol.FromBytes(data);
                        SetModuleStateCode(protocol.Module, protocol.ErrorCode);
                    }
                    break;
                case ProtocolDef.l2e_info_def:
                    {
                        l2e_info protocol = new l2e_info();
                        protocol.FromBytes(data);
                        Hashtable infoPackage = Util.ConvertKeyValuePairToHashtable(protocol.Info);
                        if (infoPackage != null)
                            GameInfoReceived(infoPackage);
                    }
                    break;
                case ProtocolDef.l2e_info_large_def:
                    {
                        l2e_info_large protocol = new l2e_info_large();
                        protocol.FromBytes(data);
                        Hashtable infoPackage = Util.ConvertKeyValuePairToHashtable(protocol.InfoLarge);
                        if (infoPackage != null)
//.........这里部分代码省略.........
开发者ID:viticm,项目名称:pap2,代码行数:101,代码来源:LordControl.cs


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