Esempio n. 1
0
 /// <summary>
 /// Der Buffer ist ein string
 /// </summary>
 public Packet(PacketInfo pInfo,string buffer)
 {
     asen = new ASCIIEncoding();
     byte[] ba = asen.GetBytes(buffer);
     byteInfo = pInfo.ToByte();
     value = ba;
     this.pInfo = pInfo;
 }
Esempio n. 2
0
        /// <summary>
        /// PacketInfo und buffer als byte[]
        /// </summary>
        public Packet(PacketInfo pInfo, byte[] buffer)
        {
            byte[] info = new byte[2];
            info[0] = pInfo.ToByte();

            byteInfo = info[0];
            asen = new ASCIIEncoding();
            value = GetPacketByte(buffer, info);
            this.pInfo = pInfo;
        }
Esempio n. 3
0
        public Packet GetPacketFromNewSocket(PacketInfo pckInfo, Socket sck)
        {
            byte[] buffer = ReadBuffer(sck, 100);
            Packet pck = new Packet(pckInfo, buffer);
            if (pck.byteInfo.ToString() != pckInfo.ToByte().ToString())
            {

                CommandLine.Write("Invalid Packet " + pckInfo.ToString() + " or wrong byteInfo(" + pck.byteInfo + ")", "warning", ConsoleColor.Yellow);
            }
            return pck;
        }
Esempio n. 4
0
        public Packet GetPacket(PacketInfo pckInfo)
        {
            try
            {
                return new Packet(Packets.ERROR);
            }

            catch
            {
                CommandLine.Write("GetPacket failed", "error", ConsoleColor.Red);
                return new Packet(Packets.ERROR);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Für die Packets die gesendet werden und es keinen buffer gibt
 /// </summary>
 public Packet(PacketInfo pInfo)
 {
     asen = new ASCIIEncoding();
     byteInfo = pInfo.ToByte();
     this.pInfo = pInfo;
 }
        public Packet GetPacket(PacketInfo pckInfo, Socket sck)
        {
            try
            {
                int l = pckInfo.length;
                byte[] buffer = new byte[l];
                buffer = ReadPacket(sck, l);
               // Packet p = new Packet(buffer);
                return new Packet();
            }

            catch (Exception ex)
            {
               //TODO:PacketReadAttempts++;
                return new Packet();
            }
        }