本文整理汇总了C#中PacketParser.Parse方法的典型用法代码示例。如果您正苦于以下问题:C# PacketParser.Parse方法的具体用法?C# PacketParser.Parse怎么用?C# PacketParser.Parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketParser
的用法示例。
在下文中一共展示了PacketParser.Parse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoParse
protected virtual void DoParse(ParsablePacketInfo info, LogHandler handler)
{
var rawPacket = info.Packet;
if (rawPacket.PacketId.IsUpdatePacket)
{
var len = rawPacket.Length - rawPacket.HeaderSize;
var bytes = rawPacket.ReadBytes(len);
if (bytes.Length != len)
{
log.Warn("BinaryReader.ReadBytes failed: {0} / {1}", bytes.Length, len);
return;
}
var updatePacket = ParsedUpdatePacket.Create(info.Timestamp,
bytes,
false,
rawPacket.PacketId == RealmServerOpCode.SMSG_COMPRESSED_UPDATE_OBJECT);
if (handler.UpdatePacketHandler != null)
{
handler.UpdatePacketHandler(updatePacket);
}
}
else
{
var parser = new PacketParser(info);
parser.Parse();
if (handler.NormalPacketHandler != null)
{
handler.NormalPacketHandler(parser);
}
}
}
示例2: Initialize
/// <summary>
/// Intializes <see cref="InputAdapter"/>.
/// </summary>
public override void Initialize()
{
Dictionary<string, string> settings = Settings;
string value;
// Example connection string:
// Port=1003; ServerID=P3
if (settings.TryGetValue("port", out value))
m_archiverPort = int.Parse(value);
if (settings.TryGetValue("historianid", out value))
m_historianID = value.Trim().ToUpper();
// Create new data parser
m_parser = new PacketParser();
m_parser.DataParsed += m_parser_DataParsed;
// Create UDP client to listen for messages
m_client = new UdpClient("localport=" + m_archiverPort);
m_client.ConnectionEstablished += m_client_ConnectionEstablished;
m_client.ConnectionTerminated += m_client_ConnectionTerminated;
m_client.ConnectionException += m_client_ConnectionException;
m_client.Handshake = false;
// Send data received over UDP port directly to packet parser
m_client.ReceiveDataHandler = (buffer, offset, count) => m_parser.Parse(Guid.Empty, buffer, offset, count);
}