Slick Sim 0.10.1
Exchange simulator that shadows real venues for risk-free strategy testing
Loading...
Searching...
No Matches
slick::sim::ControlStreams Class Reference

Cuts each connection's control-port byte stream into whole messages, keeping the part of a message that has arrived until the rest does. More...

#include <common/control_stream.hpp>

Collaboration diagram for slick::sim::ControlStreams:

Public Member Functions

 ControlStreams (size_t max_length) noexcept
 max_length is the longest message the server accepts.
template<typename OnMessage>
bool feed (int connection, const uint8_t *data, size_t size, OnMessage &&on_message)
 Hands on_message(const ControlHeader &, const uint8_t *message) every whole message data completes, header included, in order.
void erase (int connection)

Detailed Description

Cuts each connection's control-port byte stream into whole messages, keeping the part of a message that has arrived until the rest does.

For a TCP server that speaks the ControlHeader framing. Server thread only.

Definition at line 15 of file control_stream.hpp.

Constructor & Destructor Documentation

◆ ControlStreams()

slick::sim::ControlStreams::ControlStreams ( size_t max_length)
inlineexplicitnoexcept

max_length is the longest message the server accepts.

A longer header is refused as soon as it arrives rather than buffered for.

Definition at line 19 of file control_stream.hpp.

Member Function Documentation

◆ erase()

void slick::sim::ControlStreams::erase ( int connection)
inline

Definition at line 48 of file control_stream.hpp.

◆ feed()

template<typename OnMessage>
bool slick::sim::ControlStreams::feed ( int connection,
const uint8_t * data,
size_t size,
OnMessage && on_message )
inline

Hands on_message(const ControlHeader &, const uint8_t *message) every whole message data completes, header included, in order.

False when the stream is malformed (a length out of range, or on_message returned false), and the caller should close the connection.

Definition at line 26 of file control_stream.hpp.


The documentation for this class was generated from the following file: