示例#1
0
    public ProtocolTreeNode nextTree(byte[] pInput = null)
    {
        if (pInput != null)
        {
            if (pInput.Length == 0)
            {
                return(null);
            }
            this.buffer = new List <byte>();
            this.buffer.AddRange(pInput);
        }

        int stanzaFlag = (this.peekInt8() & 0xF0) >> 4;
        int stanzaSize = this.peekInt16(1);

        int flags = stanzaFlag;
        int size  = stanzaSize;

        if (stanzaSize > this.buffer.Count)
        {
            var exception = new IncompleteMessageException("Incomplete message");
            exception.setInput(this.buffer.ToArray());
            throw exception;
        }

        this.readInt24();

        bool isEncrypted = (stanzaFlag & 8) != 0;

        if (isEncrypted && Encryptionkey != null)
        {
            decode(ref this.buffer, size);
        }

        if (stanzaSize > 0)
        {
            ProtocolTreeNode node = this.nextTreeInternal();
            return(node);
        }
        return(null);
    }
    public ProtocolTreeNode nextTree(byte[] pInput = null)
    {
        if (pInput != null)
        {
            if (pInput.Length == 0)
                return null;
            this.buffer = new List<byte>();
            this.buffer.AddRange(pInput);
        }

        int stanzaFlag = (this.peekInt8() & 0xF0) >> 4;
        int stanzaSize = this.peekInt16(1);

        int flags = stanzaFlag;
        int size = stanzaSize;

        if (stanzaSize > this.buffer.Count)
        {
            var exception = new IncompleteMessageException("Incomplete message");
            exception.setInput(this.buffer.ToArray());
            throw exception;
        }

        this.readInt24();

        bool isEncrypted = (stanzaFlag & 8) != 0;

        if (isEncrypted && Encryptionkey != null)
        {
            decode(ref this.buffer, size);
        }

        if (stanzaSize > 0)
        {
            ProtocolTreeNode node = this.nextTreeInternal();
            return node;
        }
        return null;
    }