protected BlynkMessageParser(IByteProtocolBuffer byteProtocol) { try { BlynkLogManager.LogMethodBegin("BlynkMessageParser.ctor"); byte commandType; UInt16 messageId; UInt16 messageLength; byteProtocol .Extract(out commandType) .Extract(out messageId) .Extract(out messageLength); this.BlynkCommandType = ( BlynkCommandType )commandType; this.MessageId = messageId; if (this.BlynkCommandType == BlynkCommandType.BLYNK_CMD_RESPONSE) { this.ResponseCode = messageLength; this.MessageLength = ( UInt16 )0; this.messageBuffer = null; } else { this.MessageLength = messageLength; byteProtocol.Extract(out this.messageBuffer, messageLength); } } catch (Exception ex) { BlynkLogManager.LogException("Error constructing message parser", ex); } finally { BlynkLogManager.LogMethodEnd("BlynkMessageParser.ctor"); } }
public IByteProtocolBuffer Extract(out IByteProtocolBuffer protocolBuffer, int length) { try { BlynkLogManager.LogMethodBegin(nameof(Extract)); protocolBuffer = null; return(this.MessageBuffer.Extract(out protocolBuffer, length)); } finally { BlynkLogManager.LogMethodEnd(nameof(Extract)); } }
public IByteProtocolBuffer Extract(out IByteProtocolBuffer protocolBuffer, int length) { protocolBuffer = new ByteProtocolBuffer(this, length); this.memoryOffset += length; return(this); }