コード例 #1
0
        /// <summary>
        /// Processes the packet.
        /// </summary>
        /// <param name="evt">Evt.</param>
        private void ProcessPacket(Event evt)
        {
            byte[] data = new byte[1024 + 4];
            evt.Packet.CopyTo(data);

            BitBuffer buffer = new BitBuffer(128);

            buffer.FromArray(data, evt.Packet.Length);

            OpCodes op = (OpCodes)buffer.ReadInt();
            uint    id = buffer.ReadUInt();

            if (DEBUG)
            {
                Console.WriteLine($"OPCODE: {op.ToString()}");
                Console.WriteLine($"PEERID: {id.ToString()}");
            }

            if (evt.Peer.ID != id)
            {
                Console.WriteLine($"ID Mismatch! {evt.Peer.ID} vs. {id}");
                return;
            }

            Packet packet = evt.Packet;

            switch (op)
            {
            case OpCodes.PlayerLogin:
                //Answer OK
                SendToSingleClient(CreateAnswerPacketLogin("OK", evt.Peer.ID), evt.Peer.ID);
                break;
            }
        }
コード例 #2
0
            private void HandleENETMessage(Event evt)
            {
                Console.WriteLine($"\nreceived by {Context.Self.Path}" +
                                  $"\nsender {Sender.Path}\n");

                byte[] data = new byte[1024 + 4];
                evt.Packet.CopyTo(data);
                //var test = evt.Packet.Length;

                BitBuffer buffer = new BitBuffer(128);

                buffer.FromArray(data, evt.Packet.Length);

                OpCodes op = (OpCodes)buffer.ReadInt();
                uint    id = buffer.ReadUInt();

                if (DEBUG)
                {
                    Console.WriteLine($"OPCODE: {op.ToString()}");
                    Console.WriteLine($"PEERID: {id.ToString()}");
                }

                if (evt.Peer.ID != id)
                {
                    Console.WriteLine($"ID Mismatch! {evt.Peer.ID} vs. {id}");
                    return;
                }

                Packet packet = evt.Packet;

                switch (op)
                {
                case OpCodes.PlayerLogin:
                    //Answer OK
                    SendToSingleClient(CreateAnswerPacketLogin("OK", evt.Peer.ID), evt.Peer.ID);
                    break;
                }

                //Destroy all
                evt.Packet.Dispose();
            }
コード例 #3
0
 public ENETUntypedActor(Event evt)
 {
     _evt = evt;
 }