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