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


C# NetIncomingMessage.ReadProtocol方法代码示例

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


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

示例1: HandleDataMessage

        private void HandleDataMessage(NetIncomingMessage incomingMessage)
        {
            if (IsAuthenticated)
            {
                //incomingMessage.Decrypt(cryptoAlgorithm);
            }

            var p = incomingMessage.ReadProtocol();
            ushort messageType = incomingMessage.ReadUInt16();

            //Trace.WriteLine("Received " + ((CustomMessageType)messageType).ToString() + ".");

            var protocol = Protocols.Where(x => x.Equals(p)).First();

            var mHandlers = GetHandlers(protocol, messageType);
            var message = protocol.Create(messageType);
            message.ReadPayload(incomingMessage);

            if (OnMessageReceived != null)
                OnMessageReceived(null, new MessageEventArgs(this, message));

            if (mHandlers != null)
            {
                for (int n = 0; n < mHandlers.Count; ++n)
                    mHandlers[n](new MessageEventArgs(this, message));
            }
        }
开发者ID:dvgamer,项目名称:Touno.Sentinel-II,代码行数:27,代码来源:NetworkPeer.cs

示例2: HandleUnconnectedDataMessage

        private void HandleUnconnectedDataMessage(NetIncomingMessage message)
        {
            var p = message.ReadProtocol();
            ushort messageType = message.ReadUInt16();

            //Trace.WriteLine("Received " + ((CustomMessageType)messageType).ToString() + " unconnected.");

            var protocol = Protocols.Where(x => x.Equals(p)).First();

            var mHandlers = GetUnconnectedHandlers(protocol, messageType);
            var customMessage = protocol.Create(messageType);
            customMessage.ReadPayload(message);

            if (OnUnconnectedMessageReceived != null)
                OnUnconnectedMessageReceived(null, new UnconnectedMessageEventArgs(customMessage, message.SenderEndpoint));

            if (mHandlers != null)
            {
                for (int n = 0; n < mHandlers.Count; ++n)
                    mHandlers[n](new UnconnectedMessageEventArgs(customMessage, message.SenderEndpoint));
            }
        }
开发者ID:dvgamer,项目名称:Touno.Sentinel-II,代码行数:22,代码来源:NetworkPeer.cs


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