17#ifndef ESI_BACKENDS_RPCCLIENT_H
18#define ESI_BACKENDS_RPCCLIENT_H
88 const std::vector<MessageData> &frames,
94 unsigned maxInFlight);
102 std::function<std::optional<std::vector<MessageData>>()>;
129 std::unique_ptr<WriteChannelConnection>
137 std::function<bool(std::unique_ptr<SegmentedMessageData> &)>;
152 std::unique_ptr<ReadChannelConnection>
A concrete flat message backed by a single vector of bytes.
Abstract handle for a read channel connection.
virtual void disconnect()=0
virtual ~ReadChannelConnection()=default
Handle for a sender registered with connectServerSender().
virtual ~WriteChannelConnection()=default
virtual void disconnect()=0
Stop calling the callbacks.
virtual void notify()=0
Notify that the fetch callback has data again. Doesn't block.
void setToServerMaxInFlight(const std::string &channelName, unsigned maxInFlight)
Set the maximum number of unconsumed frames on a server-bound channel.
ChannelDirection
Channel direction as reported by the server.
static constexpr unsigned DefaultToClientMaxInFlight
Default maximum number of frames in flight (queued in the simulator or sent but not yet consumed by t...
std::function< bool(std::unique_ptr< SegmentedMessageData > &)> ReadCallback
Callback type for receiving messages from a client-bound channel.
static constexpr unsigned DefaultToServerMaxInFlight
Default maximum number of frames sent to a server-bound channel which the simulation has not yet cons...
std::unique_ptr< ReadChannelConnection > connectClientReceiver(const std::string &channelName, ReadCallback callback, unsigned maxInFlight=DefaultToClientMaxInFlight)
Connect to a client-bound channel and receive messages via callback.
RpcClient(Logger &logger, const std::string &hostname, uint16_t port)
bool tryWriteToServer(const std::string &channelName, const std::vector< MessageData > &frames, bool force=false)
Non-blocking send of one message, split into frames, to a server-bound channel.
std::vector< uint8_t > getCompressedManifest() const
Get the compressed manifest from the server.
uint32_t getEsiVersion() const
Get the ESI version from the manifest.
static constexpr size_t MaxSendsPerTurn
The most messages a sender sends before other channels are serviced.
std::function< std::optional< std::vector< MessageData > >()> SendFetchCallback
Data source for a server-bound channel (see connectServerSender()): returns the frames of the next me...
void writeToServer(const std::string &channelName, const MessageData &data)
Send a message to a server-bound channel.
std::function< void(std::exception_ptr)> SendErrorCallback
Called with an exception thrown by a SendFetchCallback or while sending, e.g.
bool getChannelDesc(const std::string &channelName, ChannelDesc &desc) const
Get the channel description for a channel name.
RpcClient & operator=(const RpcClient &)=delete
std::vector< ChannelDesc > listChannels() const
List all channels available on the server.
std::unique_ptr< WriteChannelConnection > connectServerSender(const std::string &channelName, SendFetchCallback fetch, SendErrorCallback onError)
Send to a server-bound channel in callback (pull) mode, like WriteChannelPort's callback mode.
std::unique_ptr< Impl > impl
RpcClient(const RpcClient &)=delete
Description of a channel from the server.