private void OnDataSent(object sender, ByteDataEventArgs e)
 {
     var packets = PacketSerializer.Deserialize(e.ByteData);
     if (packets != null)
     {
         foreach (var packet in packets)
         {
             InvokePacketSent(packet);
         }
     }
 }
        private void OnDataReceived(object sender, ByteDataEventArgs e)
        {
            var packets = PacketSerializer.Deserialize(e.ByteData);

            if (packets != null)
            {
                foreach (var packet in packets)
                {
                    PacketSequence.CurrentSequenceId = Convert.ToInt32(packet.SequenceId);

                    InvokePacketReceived(packet);
                    if (packet.IsClientCommand)
                    {
                        this.InvokeClientCommandReceived(packet);
                    }
                    if (packet.IsServerEventResponse)
                    {
                        this.InvokeServerEventResponseReceived(packet);
                    }
                }
            }
        }