本文整理汇总了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());
}
示例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));
}
}