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); }
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; }
public ProtocolTreeNode nextTree(string pInput = null) { if (pInput != null) { this.input = pInput; } int stanzaSize = this.peekInt16(); if (stanzaSize > this.input.Length) { //Es sind noch nicht alle Daten eingelesen, daher abbrechen und warten bis alles da ist var exception = new IncompleteMessageException("Incomplete message"); exception.setInput(this.input); throw exception; } this.readInt16(); if (stanzaSize > 0) { return this.nextTreeInternal(); } return null; }
public ProtocolTreeNode nextTree(string pInput = null) { if (pInput != null) { this.input = pInput; } int stanzaSize = this.peekInt16(); if (stanzaSize > this.input.Length) { //Es sind noch nicht alle Daten eingelesen, daher abbrechen und warten bis alles da ist var exception = new IncompleteMessageException("Incomplete message"); exception.setInput(this.input); throw exception; } this.readInt16(); if (stanzaSize > 0) { return(this.nextTreeInternal()); } return(null); }
//public ProtocolTreeNode nextTree(string pInput = null) //{ // if (pInput != null) // { // this.input = pInput; // } // //int stanzaSize = this.peekInt16(); // //Change to protocol 1.2 // int stanzaSize = this.peekInt24(); // int flags = (stanzaSize >> 20); // int size = ((stanzaSize & 0xF0000) >> 16) | ((stanzaSize & 0xFF00) >> 8) | (stanzaSize & 0xFF); // bool isEncrypted = ((flags & 8) != 0); // 8 = (1 << 4) // Read node and decrypt // if (stanzaSize > this.input.Length) // { // //Es sind noch nicht alle Daten eingelesen, daher abbrechen und warten bis alles da ist // var exception = new IncompleteMessageException("Incomplete message"); // exception.setInput(this.input); // throw exception; // } // this.readInt24(); // if (stanzaSize > 0) // { // if (isEncrypted && Encryptionkey != null) // { // RC4 encryption = new RC4(this.Encryptionkey, 256); // byte[] dataB = this.sysEncoding.GetBytes(this.input); // byte[] enData = new byte[dataB.Length - 3]; // Buffer.BlockCopy(dataB, 3, enData, 0, dataB.Length - 3); // //encryption.Cipher(enData, 0, dataB.Length - 3); // enData = encryption.Encrypt(enData); // Buffer.BlockCopy(enData, 0, dataB, 3, enData.Length); // } // return this.nextTreeInternal(); // } // 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); } // Ported from the allegedly working PHP version ~lrg 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(size); } if(stanzaSize > 0) { ProtocolTreeNode node = this.nextTreeInternal(); if (node != null) this.DebugPrint(node.NodeString("RECVD: ")); return node; } return null; }