class streaming_producer - 5cript/attender GitHub Wiki

class streaming_producer

class streaming_producer
  : public attender::producer

An example producer that uses chunked encoding for data that is streamed into the connection and then at some point completes.

Summary

Members Descriptions
public streaming_producer(std::string encoding,std::function< void()> on_ready,std::function< void(boost::system::error_code)> on_error)
public virtual std::string encoding() const Returns the encoding the producer provides.
public virtual std::size_t available() const The amount of available data in the buffer.
public virtual char const * data() const A pointer to the begin of the buffer.
public virtual bool complete() const Returns whether the data production has ended.
public virtual void has_consumed(std::size_t size) The base class calls this function to signal that some data has been consumed.
public virtual void on_error(boost::system::error_code) This function is called when the write function returns an error.
public virtual void start_production() The server calls this function when a consumer is attached.
public void flush() Indicate that data was produced and shall be written.
public virtual void buffer_locked_do(std::function< void()> const &) const Everything within the supplied function is guarded by a mutex that also guards other buffer accesses.
public void finish() Set stream as complete.

Members


public streaming_producer(std::string encoding,std::function< void()> on_ready,std::function< void(boost::system::error_code)> on_error)


public virtual std::string encoding() const

Returns the encoding the producer provides.


public virtual std::size_t available() const

The amount of available data in the buffer.


public virtual char const * data() const

A pointer to the begin of the buffer.


public virtual bool complete() const

Returns whether the data production has ended.


public virtual void has_consumed(std::size_t size)

The base class calls this function to signal that some data has been consumed.

Always call the base class function at the end of your implementation.


public virtual void on_error(boost::system::error_code)

This function is called when the write function returns an error.

Use this to stop any production.


public virtual void start_production()

The server calls this function when a consumer is attached.


public void flush()

Indicate that data was produced and shall be written.


public virtual void buffer_locked_do(std::function< void()> const &) const

Everything within the supplied function is guarded by a mutex that also guards other buffer accesses.


public void finish()

Set stream as complete.

⚠️ **GitHub.com Fallback** ⚠️