Exemplo n.º 1
0
        public TextTransferPacket(byte[] data)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(data);
            PacketType = Encoding.ASCII.GetString(buffer.ReadBytes(4));
            PacketText = buffer.ReadString();

            buffer.Dispose();
        }
        /// <summary>
        /// Deserializes a data buffer into a ScoutResponsePacket
        /// </summary>
        /// <param name="data"></param>
        /// <param name="endPoint"></param>
        public ScoutResponsePacket(byte[] data, IPEndPoint endPoint)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(data);
            PacketType     = Encoding.Default.GetString(buffer.ReadBytes(4));
            PacketData     = new byte[data.Length - 4];
            PacketEndPoint = endPoint;
            Array.Copy(data, 4, PacketData, 0, PacketData.Length);
            buffer.Dispose();
        }