/// <summary> /// Parse the bytes given, and return the number of commands parsed. /// </summary> /// <param name="bytes">The bytes representing the commands</param> /// <returns>The number of commands parsed</returns> private static int parseBytes(byte[] bytes) { int commands = 0; ConnectionState parser = new ConnectionState(); parser.setObjectReceivedAction(args => commands++); parser.buffer = bytes; try { parser.update(bytes.Length); } catch { return 1; } return commands; }
/// <summary> /// Parse the bytes given, and return the number of commands parsed. /// </summary> /// <param name="bytes">The bytes representing the commands</param> /// <returns>The number of commands parsed</returns> private static int parseBytes(byte[] bytes) { int commands = 0; ConnectionState parser = new ConnectionState(); parser.setObjectReceivedAction(args => commands++); parser.buffer = bytes; try { parser.update(bytes.Length); } catch { return(1); } return(commands); }
/// <summary> /// Advance the buffer in the state object. /// </summary> /// <param name="state">The state object</param> /// <param name="bytesRead">The number of bytes read from the socket.</param> private static void updateState(ConnectionState state, int bytesRead) { state.update(bytesRead); }