public static bool ReadNextCommand(byte[] payload, int offset, out ParsedCommandSpec?cmd) { cmd = null; if (payload.Length < offset + 8) { return(false); } int cmdLength = (payload[offset] << 8) | payload[offset + 1]; if (payload.Length < offset + cmdLength || cmdLength == 0) { return(false); } byte[] cmdBody = new byte[cmdLength - 8]; Array.Copy(payload, offset + 8, cmdBody, 0, cmdLength - 8); string name = Encoding.ASCII.GetString(payload, offset + 4, 4); cmd = new ParsedCommandSpec(name, cmdBody); return(true); }
public ParsedCommand(ParsedCommandSpec spec) : base(spec.Body, true) { Name = spec.Name; }