Exemple #1
0
        private void Svr_ReceivedPacket(object sender, ReceivedPacketEventArgs e)
        {
            EzClient client = Clients.GetClient(e.Socket);
            EzPacket packet = client.Read(e.Data);

            if (packet != null)
            {
                if (_handlers.ContainsKey(packet.Id))
                {
                    _logger.LogIncomingPacket(client, packet);
                    packet.Data.SetPositionStart();
                    _handlers[packet.Id].Handle(client, packet);
                }
                else
                {
                    _logger.LogUnknownOutgoingPacket(client, packet);
                }
            }
        }
 private void ClientConsumerOnReceivedPacket(object sender, ReceivedPacketEventArgs e)
 {
     byte[] data = e.Data;
     Console.WriteLine(string.Format("Demo: Client: received packet Size:{0}", data.Length));
 }
 private void ServerConsumerOnReceivedPacket(object sender, ReceivedPacketEventArgs e)
 {
     byte[] received = e.Data;
     Console.WriteLine(string.Format("Demo: Server: received packet Size:{0}", received.Length));
     e.Socket.Send(new byte[10]);
 }