Пример #1
0
        public CharLogonResponsePacket(McpPacket packet) : base(packet.Raw)
        {
            var reader = new BinaryReader(new MemoryStream(Raw), Encoding.ASCII);

            if (Raw.Length != reader.ReadUInt16())
            {
                throw new McpPacketException("Packet length does not match");
            }
            if (Mcp.CHARLOGON != (Mcp)reader.ReadByte())
            {
                throw new McpPacketException("Expected Packet Type Not Found");
            }
            Result = reader.ReadUInt32();
        }
Пример #2
0
        public static void HandleIncomingPacket(McpPacket eventArgs)
        {
            if (!Enum.IsDefined(typeof(Mcp), eventArgs.Type))
            {
                Log.Information($"Received unknown MCP packet of type: 0x{(byte)eventArgs.Type,2:X2} with data {eventArgs.Raw.ToPrintString()}");
                return;
            }

            var incomingPacketType = (Mcp)eventArgs.Type;

            switch (incomingPacketType)
            {
            case Mcp.STARTUP:
            case Mcp.CHARCREATE:
            case Mcp.CREATEGAME:
            case Mcp.JOINGAME:
            case Mcp.GAMELIST:
            case Mcp.GAMEINFO:
            case Mcp.CHARLOGON:
            case Mcp.CHARDELETE:
            case Mcp.REQUESTLADDERDATA:
            case Mcp.MOTD:
            case Mcp.CANCELGAMECREATE:
            case Mcp.CREATEQUEUE:
            case Mcp.CHARRANK:
            case Mcp.CHARLIST:
            case Mcp.CHARUPGRADE:
            case Mcp.CHARLIST2:
                if (Log.IsEnabled(Serilog.Events.LogEventLevel.Debug))
                {
                    Log.Debug($"Received MCP packet of type: {incomingPacketType} with data { eventArgs.Raw.ToPrintString()}");
                }
                else
                {
                    Log.Information($"Received MCP packet of type: {incomingPacketType}");
                }
                break;
            }
        }
Пример #3
0
 public void Set(McpPacket packet)
 {
     _packet = packet;
     _event.Set();
 }
Пример #4
0
 public void Reset()
 {
     _event.Reset();
     _packet = null;
 }