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


C# NetIncomingMessage.Decrypt方法代码示例

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


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

示例1: IncomingMessage

        /// <summary>
        /// This handles an incoming message 
        /// </summary>
        /// <param name="msg">The received message</param>
        public void IncomingMessage(NetIncomingMessage msg)
        {
            if (!this.IsConnected)
                return;

            // Is this is a heartbeat message? (keep alive)
            if (msg.LengthBits == 0)
                return;

            // Decrypt the message
            msg.Decrypt(_netEncryption);
            if (msg.LengthBits == 0)
                return;

            // Here you can process your message like:
            Console.WriteLine("Received message: {0}", msg.ReadString());
        }
开发者ID:SleeplessByte,项目名称:lidgren-srp6a,代码行数:21,代码来源:Connection.cs

示例2: ProcessNetIncomingMessageData

        private void ProcessNetIncomingMessageData(NetIncomingMessage message, bool unconnected)
        {
            try
            {
                if (!unconnected)
                {
                    switch (message.SequenceChannel)
                    {
                        case 0: // Assume everything sent along channel 0 is encrypted
                            if (!message.Decrypt(_encryption))
                            {
                                Log.Critical("Unable to decrypt packet on Channel 0, please check the key that is being used.");
                            }
                            break;
                    }
                }

                //var data = Illisian.UnityUtil.Compression.ByteArrays.Decompress(message.ReadBytes(message.LengthBytes));
                var data = message.ReadBytes(message.LengthBytes);
                NetMessage _msg = new NetMessage();
                _msg.NetConnection = message.SenderConnection;
                _msg.Object = Illisian.UnityUtil.Serialise.Binary.ByteArrayToObject(data);
                _msg.SequenceChannel = message.SequenceChannel;
                _msg.UnconnectedMessage = unconnected;

                if (OnIncomingMessage != null)
                {
                    OnIncomingMessage(_msg);
                }
                else
                {
                    Log.Warn("Packets are being received but nothing is listening on the event hook");
                }
            }
            catch (Exception ex)
            {
                Log.Warn(String.Format("Unable to Process Incoming Message :: Error Message: {0}", ex.Message));
            }
        }
开发者ID:Azerothian,项目名称:Empire,代码行数:39,代码来源:LidgrenBase.cs


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