Example #1
0
 internal RCONPacket()
 {
     RequestId          = 0;
     String1            = "blah";
     String2            = String.Empty;
     ServerDataSent     = SERVERDATA_sent.None;
     ServerDataReceived = SERVERDATA_rec.None;
 }
Example #2
0
        internal void ParseFromBytes(byte[] bytes, SourceRcon parent)
        {
            int       BPtr = 0;
            ArrayList stringcache;
            var       utf = new UTF8Encoding();

            // First 4 bytes are ReqId.
            RequestId = BitConverter.ToInt32(bytes, BPtr);
            BPtr     += 4;
            // Next 4 are server data.
            ServerDataReceived = (SERVERDATA_rec)BitConverter.ToInt32(bytes, BPtr);
            BPtr += 4;
            // string1 till /0
            stringcache = new ArrayList();
            while (bytes[BPtr] != 0)
            {
                stringcache.Add(bytes[BPtr]);
                BPtr++;
            }
            String1 = utf.GetString((byte[])stringcache.ToArray(typeof(byte)));
            BPtr++;

            // string2 till /0

            stringcache = new ArrayList();
            while (bytes[BPtr] != 0)
            {
                stringcache.Add(bytes[BPtr]);
                BPtr++;
            }
            String2 = utf.GetString((byte[])stringcache.ToArray(typeof(byte)));
            BPtr++;

            // Repeat if there's more data?

            if (BPtr != bytes.Length)
            {
                parent.OnError("Urk, extra data!");
            }
        }