ark::comms::ThrottledWebsocketWriter

Defined in header “ark/comms/throttled_websocket_writer.hh”.


This class is intended to act as a ’throttle’ for sending messages and content over a standard websocket (or anything that accepts byte buffer outputs).

It works by keeping a local queue of messages of some fixed size, and then ensuring only some number of messages are on the wire (and unacknowledged) at once. Messages are FIFO, and we drop oldest first.

Methods

  • ThrottledWebsocketWriter(ThrottledWebsocketWriterConfig config, ThrottledWebsocketWriteCallback callback)
    Constructor. Creates a new throttled writer. This will invoke the given function pointer when it has data that needs to be written.

  • ~ThrottledWebsocketWriter()
    Destructor. Cleans up internal resources.

  • void write(const core::ByteBuffer & buffer)
    Pushes a serialized message onto the queue. This will be written to the underlying websocket once all the conditions are met (the client is keeping up with data).

  • void handle_client_acknowledgement(uint16_t sequence_number)
    Invoked when the client has acknowledged a message. This is the sequence number of the message they are acknowledging. All sequence numbers prior to this one are assumed also to be acknowledged.