|
CIRCT 24.0.0git
|
A client for the cosim RPC server. More...
#include <RpcClient.h>

Classes | |
| struct | ChannelDesc |
| Description of a channel from the server. More... | |
| class | ReadChannelConnection |
| Abstract handle for a read channel connection. More... | |
| class | Impl |
Public Types | |
| enum class | ChannelDirection { ToServer , ToClient } |
| Channel direction as reported by the server. More... | |
| using | ReadCallback |
| Callback type for receiving messages from a client-bound channel. | |
Public Member Functions | |
| RpcClient (Logger &logger, const std::string &hostname, uint16_t port) | |
| ~RpcClient () | |
| RpcClient (const RpcClient &)=delete | |
| RpcClient & | operator= (const RpcClient &)=delete |
| uint32_t | getEsiVersion () const |
| Get the ESI version from the manifest. | |
| std::vector< uint8_t > | getCompressedManifest () const |
| Get the compressed manifest from the server. | |
| bool | getChannelDesc (const std::string &channelName, ChannelDesc &desc) const |
| Get the channel description for a channel name. | |
| std::vector< ChannelDesc > | listChannels () const |
| List all channels available on the server. | |
| void | writeToServer (const std::string &channelName, const MessageData &data) |
| Send a message to a server-bound channel. | |
| 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. | |
| void | setToServerMaxInFlight (const std::string &channelName, unsigned maxInFlight) |
| Set the maximum number of unconsumed frames on a server-bound channel. | |
| 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. | |
Static Public Attributes | |
| static constexpr unsigned | DefaultToServerMaxInFlight = 16 |
| Default maximum number of frames sent to a server-bound channel which the simulation has not yet consumed. | |
| static constexpr unsigned | DefaultToClientMaxInFlight = 32 |
| Default maximum number of frames in flight (queued in the simulator or sent but not yet consumed by the client) on a client-bound channel. | |
Private Attributes | |
| std::unique_ptr< Impl > | impl |
A client for the cosim RPC server.
Hides the WebSocket + JSON transport behind a small C++ API; see cosim-protocol.md for the wire format.
Definition at line 34 of file RpcClient.h.
Callback type for receiving messages from a client-bound channel.
Return true if the message was consumed, false to retry the same owning message object.
Definition at line 97 of file RpcClient.h.
|
strong |
Channel direction as reported by the server.
| Enumerator | |
|---|---|
| ToServer | |
| ToClient | |
Definition at line 50 of file RpcClient.h.
| RpcClient::RpcClient | ( | Logger & | logger, |
| const std::string & | hostname, | ||
| uint16_t | port ) |
Definition at line 932 of file RpcClient.cpp.
References impl.
Referenced by operator=(), and RpcClient().
|
default |
|
delete |
References RpcClient().
| std::unique_ptr< RpcClient::ReadChannelConnection > RpcClient::connectClientReceiver | ( | const std::string & | channelName, |
| ReadCallback | callback, | ||
| unsigned | maxInFlight = DefaultToClientMaxInFlight ) |
Connect to a client-bound channel and receive messages via callback.
maxInFlight is the maximum number of frames the simulator may have in flight for this channel; zero means unbounded. A frame stops counting once callback returns true for it. Returns a handle that disconnects when destroyed.
Definition at line 969 of file RpcClient.cpp.
References impl.
| bool RpcClient::getChannelDesc | ( | const std::string & | channelName, |
| ChannelDesc & | desc ) const |
Get the channel description for a channel name.
Returns true if the channel was found.
Definition at line 943 of file RpcClient.cpp.
References impl.
| std::vector< uint8_t > RpcClient::getCompressedManifest | ( | ) | const |
Get the compressed manifest from the server.
Definition at line 939 of file RpcClient.cpp.
References impl.
| uint32_t RpcClient::getEsiVersion | ( | ) | const |
Get the ESI version from the manifest.
Definition at line 937 of file RpcClient.cpp.
References impl.
| std::vector< RpcClient::ChannelDesc > RpcClient::listChannels | ( | ) | const |
List all channels available on the server.
Definition at line 948 of file RpcClient.cpp.
References impl.
References RpcClient().
| void RpcClient::setToServerMaxInFlight | ( | const std::string & | channelName, |
| unsigned | maxInFlight ) |
Set the maximum number of unconsumed frames on a server-bound channel.
Zero means unbounded.
Definition at line 963 of file RpcClient.cpp.
References impl.
| bool RpcClient::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.
If the channel is below its in-flight limit, sends all of them (possibly overshooting the limit by frames.size() - 1) and returns true. Otherwise sends nothing and returns false. With force, sends regardless of the limit (but still counts the frames as in flight); for the rest of a message whose first part was admitted.
Definition at line 957 of file RpcClient.cpp.
References impl.
| void RpcClient::writeToServer | ( | const std::string & | channelName, |
| const MessageData & | data ) |
Send a message to a server-bound channel.
Blocks while the channel's in-flight limit is reached. Throws if the connection is lost. Frames sent before the simulation has connected its end of the channel are held by the server (and count as in flight), not dropped.
Definition at line 952 of file RpcClient.cpp.
References impl.
|
staticconstexpr |
Default maximum number of frames in flight (queued in the simulator or sent but not yet consumed by the client) on a client-bound channel.
Definition at line 71 of file RpcClient.h.
Referenced by esi::cosim::RpcServer::Impl::handleSubscribe().
|
staticconstexpr |
Default maximum number of frames sent to a server-bound channel which the simulation has not yet consumed.
Definition at line 68 of file RpcClient.h.
|
private |
Definition at line 121 of file RpcClient.h.
Referenced by connectClientReceiver(), getChannelDesc(), getCompressedManifest(), getEsiVersion(), listChannels(), RpcClient(), setToServerMaxInFlight(), tryWriteToServer(), and writeToServer().