예제 #1
0
    private void DispatchEvent(Packet packet)
    {
        ushort packetid = packet.ReadPacketid();

        Log.Debug("Net Received server protocol id: " + packetid);

        if (this._msg_eventhandler_map.ContainsKey(packetid))
        {
            EventHandler eventHandler = this._msg_eventhandler_map[packetid];
            if (eventHandler != null)
            {
                eventHandler(packetid, P2P.PacketToProtocol(packetid, packet));
            }
        }
    }
예제 #2
0
    private static void DoMsg(Socket clientSocket, ushort packetid, Packet packet)
    {
        Console.WriteLine("packetid: {0}", packetid);

        switch (packetid)
        {
        case 40040:
            // ReqTestXX reqTestXX = new ReqTestXX(packet);
            ReqTestXX reqTestXX = P2P.PacketToProtocol(packetid, packet) as ReqTestXX;

            Console.WriteLine("{0} {1} {2} {3} {4}", reqTestXX.id_u8, reqTestXX.id_u16, reqTestXX.id_u32, reqTestXX.repeat_id_u8, reqTestXX.optional_id_u8);

            AckTestXX ackTestXX = new AckTestXX();
            ackTestXX.id_u8          = 111;
            ackTestXX.id_u16         = 11111;
            ackTestXX.id_u32         = 1111111;
            ackTestXX.optional_id_u8 = 222;
            ackTestXX.repeat_id_u8   = new List <byte>();

            clientSocket.Send(ackTestXX.Encode().GetBufferBytes());

            break;
        }
    }