Ejemplo n.º 1
0
        public void HandleRequest(byte[] buffer, int length)
        {
            Touch();

            int headerSize = (((buffer[9] >> 3) & 4) + ((buffer[9] >> 3) & 2) + 12);

            Component   componentID = (Component)(buffer[3] | (buffer[2] << 8));
            int         commandID   = buffer[5] | (buffer[4] << 8);
            int         errorCode   = buffer[7] | (buffer[6] << 8);
            MessageType messageType = (MessageType)((buffer[8] >> 4) << 16);
            int         messageID   = buffer[11] | ((buffer[10] | ((buffer[9] & 0xF) << 8)) << 8);

            int payloadSize = buffer[1] | (buffer[0] << 8);

            if (Convert.ToBoolean(buffer[9] & 0x10))
            {
                payloadSize |= (buffer[13] | (buffer[12] << 8) >> 16);
            }

            byte[] payload = buffer.Skip(headerSize).Take(payloadSize).ToArray();

            var decoder     = new TdfDecoder(payload);
            var requestData = decoder.Decode();

            var request = new Request(this);

            request.ComponentID = componentID;
            request.CommandID   = (ushort)commandID;
            request.ErrorCode   = errorCode;
            request.MessageID   = messageID;
            request.Data        = requestData;

            HandleRequest(request);
        }
Ejemplo n.º 2
0
        public void HandleRequest(byte[] buffer, int length)
        {
            Touch();

            int headerSize = (((buffer[9] >> 3) & 4) + ((buffer[9] >> 3) & 2) + 12);

            Component componentID = (Component)(buffer[3] | (buffer[2] << 8));
            int commandID = buffer[5] | (buffer[4] << 8);
            int errorCode = buffer[7] | (buffer[6] << 8);
            MessageType messageType = (MessageType)((buffer[8] >> 4) << 16);
            int messageID = buffer[11] | ((buffer[10] | ((buffer[9] & 0xF) << 8)) << 8);

            int payloadSize = buffer[1] | (buffer[0] << 8);

            if (Convert.ToBoolean(buffer[9] & 0x10))
            {
                payloadSize |= (buffer[13] | (buffer[12] << 8) >> 16);
            }

            byte[] payload = buffer.Skip(headerSize).Take(payloadSize).ToArray();

            var decoder = new TdfDecoder(payload);
            var requestData = decoder.Decode();

            var request = new Request(this);

            request.ComponentID = componentID;
            request.CommandID = (ushort)commandID;
            request.ErrorCode = errorCode;
            request.MessageID = messageID;
            request.Data = requestData;

            HandleRequest(request);
        }