public ProtocolTreeNode nextTree(byte[] pInput = null, bool useDecrypt = true)
{
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)
{
if (Encryptionkey != null)
{
decode(size, useDecrypt);
}
else
{
throw new Exception("Received encrypted message, encryption key not set");
}
}
if (stanzaSize > 0)
{
ProtocolTreeNode node = this.nextTreeInternal();
if (node != null)
{
this.DebugPrint(node.NodeString("RECVD: "));
}
return(node);
}
return(null);
}