|
CIRCT 24.0.0git
|

Classes | |
| struct | ChannelInfo |
| struct | ClientSession |
Public Member Functions | |
| Impl (Context &ctxt, int port) | |
| ~Impl () | |
| Context & | getContext () |
| void | setManifest (int esiVersion, const std::vector< uint8_t > &compressedManifest) |
| ReadChannelPort & | registerReadPort (const std::string &name, const std::string &type) |
| WriteChannelPort & | registerWritePort (const std::string &name, const std::string &type) |
| void | messageConsumed (ReadChannelPort &port) |
| void | stop (uint32_t timeoutMS) |
| int | getPort () const |
| void | logRefusedFrame (uint64_t channelId, size_t size) |
| Log that a size-byte frame for channel channelId was dropped since the simulator-side consumer refused it. | |
Public Attributes | |
| utils::ReadyIdSet< uint64_t > | readyIds |
Private Types | |
| using | ChannelDirection = backends::cosim::RpcClient::ChannelDirection |
Private Member Functions | |
| std::shared_ptr< ClientSession > | getSession () |
| The active session, if any. | |
| std::shared_ptr< ClientSession > | sessionFor (const ix::WebSocket &ws) |
| The active session if ws is its socket, else null. | |
| void | onClientMessage (const std::weak_ptr< ix::WebSocket > &wsWeak, ix::WebSocket &ws, const ix::WebSocketMessagePtr &msg) |
| void | onOpen (const std::weak_ptr< ix::WebSocket > &wsWeak) |
| void | onClose (ix::WebSocket &ws) |
| void | handleBinaryFrame (uint64_t generation, const std::string &data) |
| void | handleControlFrame (ix::WebSocket &ws, const std::string &text) |
| void | handleEvent (uint64_t generation, const json &frame) |
| void | handleHello (ix::WebSocket &ws, uint64_t requestId, const json ¶ms) |
| void | handleSubscribe (ix::WebSocket &ws, uint64_t requestId, const json ¶ms) |
| void | handleUnsubscribe (ix::WebSocket &ws, uint64_t requestId, const json ¶ms) |
| std::optional< ChannelInfo > | findChannel (ix::WebSocket &ws, uint64_t requestId, uint64_t channelId, ChannelDirection dir) |
| Look up a channel. | |
| void | sendResult (ix::WebSocket &ws, uint64_t requestId, const json &result) |
| void | sendError (ix::WebSocket &ws, uint64_t requestId, const std::string &code, const std::string &message) |
| void | transportLoop () |
| void | sendConsumedEvent (const std::unordered_set< uint64_t > &ids) |
| Send a batched consumed event for any to-server messages the simulation has consumed since the last call. | |
| void | retireSession (uint64_t generation) |
| Forget all per-channel state belonging to client session generation, which has disconnected. | |
Private Attributes | |
| Context & | ctxt |
| std::mutex | manifestMutex |
| std::condition_variable | manifestReadyCV |
| int | esiVersion = -1 |
| std::vector< uint8_t > | compressedManifest |
| bool | manifestReady = false |
| std::mutex | channelsMutex |
| std::map< std::string, std::unique_ptr< RpcServerReadPort > > | readPorts |
| std::map< std::string, std::unique_ptr< RpcServerWritePort > > | writePorts |
| std::unordered_map< uint64_t, ChannelInfo > | channelById |
| std::unordered_map< std::string, uint64_t > | idByName |
| uint64_t | nextChannelId = 0 |
| std::mutex | sessionMutex |
| std::shared_ptr< ClientSession > | session |
| uint64_t | nextSessionGeneration = 1 |
| std::thread | transportThread |
| std::unique_ptr< ix::WebSocketServer > | server |
| int | boundPort = -1 |
| ::esi::cosim::FaultStash | faultStash |
Definition at line 129 of file RpcServer.cpp.
|
private |
Definition at line 162 of file RpcServer.cpp.
| Impl::Impl | ( | Context & | ctxt, |
| int | port ) |
Definition at line 673 of file RpcServer.cpp.
References boundPort, ctxt, onClientMessage(), server, transportLoop(), and transportThread.
| Impl::~Impl | ( | ) |
Definition at line 727 of file RpcServer.cpp.
|
private |
Look up a channel.
If it doesn't exist or doesn't have direction dir, reply with an error and return nullopt.
Definition at line 1244 of file RpcServer.cpp.
References channelById, channelsMutex, and sendError().
Referenced by handleSubscribe().
|
inline |
Definition at line 134 of file RpcServer.cpp.
References ctxt.
|
inline |
Definition at line 146 of file RpcServer.cpp.
References boundPort.
|
inlineprivate |
The active session, if any.
The returned pointer stays valid after the client disconnects; sends on it then just fail.
Definition at line 229 of file RpcServer.cpp.
References session, and sessionMutex.
Referenced by sendConsumedEvent(), sessionFor(), and transportLoop().
|
private |
Definition at line 927 of file RpcServer.cpp.
References channelById, channelsMutex, ctxt, esi::MessageData::getSize(), logRefusedFrame(), and esi::cosim::parseDataFrame().
Referenced by onClientMessage().
|
private |
Definition at line 973 of file RpcServer.cpp.
References ctxt, faultStash, handleEvent(), handleHello(), handleSubscribe(), handleUnsubscribe(), sendError(), and sessionFor().
Referenced by onClientMessage().
|
private |
Definition at line 1066 of file RpcServer.cpp.
References channelById, channelsMutex, ctxt, and parseConsumedEvent().
Referenced by handleControlFrame().
|
private |
Definition at line 1095 of file RpcServer.cpp.
References channelById, channelsMutex, compressedManifest, esiVersion, esi::cosim::kProtocolVersion, manifestMutex, manifestReady, manifestReadyCV, nextChannelId, sendError(), sendResult(), and sessionFor().
Referenced by handleControlFrame().
|
private |
Definition at line 1152 of file RpcServer.cpp.
References esi::backends::cosim::RpcClient::DefaultToClientMaxInFlight, findChannel(), readyIds, sendError(), sendResult(), and sessionFor().
Referenced by handleControlFrame().
|
private |
Definition at line 1202 of file RpcServer.cpp.
References channelById, channelsMutex, sendError(), sendResult(), and sessionFor().
Referenced by handleControlFrame().
| void Impl::logRefusedFrame | ( | uint64_t | channelId, |
| size_t | size ) |
Log that a size-byte frame for channel channelId was dropped since the simulator-side consumer refused it.
Definition at line 966 of file RpcServer.cpp.
References ctxt.
Referenced by handleBinaryFrame().
| void Impl::messageConsumed | ( | ReadChannelPort & | port | ) |
Definition at line 774 of file RpcServer.cpp.
|
private |
Definition at line 834 of file RpcServer.cpp.
References ctxt, faultStash, handleBinaryFrame(), handleControlFrame(), onClose(), onOpen(), and sessionFor().
Referenced by Impl().
|
private |
Definition at line 902 of file RpcServer.cpp.
References retireSession(), session, and sessionMutex.
Referenced by onClientMessage().
|
private |
Definition at line 872 of file RpcServer.cpp.
References ctxt, nextSessionGeneration, session, and sessionMutex.
Referenced by onClientMessage().
| ReadChannelPort & Impl::registerReadPort | ( | const std::string & | name, |
| const std::string & | type ) |
Definition at line 759 of file RpcServer.cpp.
References channelById, channelsMutex, faultStash, idByName, nextChannelId, and readPorts.
| WriteChannelPort & Impl::registerWritePort | ( | const std::string & | name, |
| const std::string & | type ) |
Definition at line 780 of file RpcServer.cpp.
References channelById, channelsMutex, faultStash, idByName, nextChannelId, and writePorts.
|
private |
Forget all per-channel state belonging to client session generation, which has disconnected.
Definition at line 919 of file RpcServer.cpp.
References channelsMutex, readPorts, and writePorts.
Referenced by onClose().
|
private |
Send a batched consumed event for any to-server messages the simulation has consumed since the last call.
Transport thread only.
Definition at line 1348 of file RpcServer.cpp.
References channelById, channelsMutex, and getSession().
Referenced by transportLoop().
|
private |
Definition at line 1281 of file RpcServer.cpp.
Referenced by findChannel(), handleControlFrame(), handleHello(), handleSubscribe(), and handleUnsubscribe().
|
private |
Definition at line 1270 of file RpcServer.cpp.
Referenced by handleHello(), handleSubscribe(), and handleUnsubscribe().
|
inlineprivate |
The active session if ws is its socket, else null.
Requests are handled through this, so one still being handled when its client disconnects can't act on a replacement client's session.
Definition at line 236 of file RpcServer.cpp.
References getSession().
Referenced by handleControlFrame(), handleHello(), handleSubscribe(), handleUnsubscribe(), and onClientMessage().
| void Impl::setManifest | ( | int | esiVersion, |
| const std::vector< uint8_t > & | compressedManifest ) |
Definition at line 747 of file RpcServer.cpp.
References compressedManifest, esiVersion, faultStash, manifestMutex, manifestReady, and manifestReadyCV.
| void Impl::stop | ( | uint32_t | timeoutMS | ) |
Definition at line 795 of file RpcServer.cpp.
References channelsMutex, faultStash, readPorts, readyIds, server, session, sessionMutex, transportThread, and writePorts.
Referenced by ~Impl().
|
private |
Definition at line 1297 of file RpcServer.cpp.
References esi::cosim::buildDataFrame(), channelById, channelsMutex, getSession(), readyIds, and sendConsumedEvent().
Referenced by Impl().
|
private |
Definition at line 248 of file RpcServer.cpp.
|
private |
Definition at line 218 of file RpcServer.cpp.
Referenced by findChannel(), handleBinaryFrame(), handleEvent(), handleHello(), handleUnsubscribe(), registerReadPort(), registerWritePort(), sendConsumedEvent(), and transportLoop().
|
private |
Definition at line 215 of file RpcServer.cpp.
Referenced by findChannel(), handleBinaryFrame(), handleEvent(), handleHello(), handleUnsubscribe(), registerReadPort(), registerWritePort(), retireSession(), sendConsumedEvent(), stop(), and transportLoop().
|
private |
Definition at line 210 of file RpcServer.cpp.
Referenced by handleHello(), and setManifest().
|
private |
Definition at line 203 of file RpcServer.cpp.
Referenced by getContext(), handleBinaryFrame(), handleControlFrame(), handleEvent(), Impl(), logRefusedFrame(), esiaccel.accelerator.AcceleratorConnection::manifest(), onClientMessage(), onOpen(), and ~Impl().
|
private |
Definition at line 209 of file RpcServer.cpp.
Referenced by handleHello(), and setManifest().
|
private |
Definition at line 282 of file RpcServer.cpp.
Referenced by handleControlFrame(), onClientMessage(), registerReadPort(), registerWritePort(), setManifest(), and stop().
|
private |
Definition at line 219 of file RpcServer.cpp.
Referenced by registerReadPort(), and registerWritePort().
|
private |
Definition at line 207 of file RpcServer.cpp.
Referenced by handleHello(), and setManifest().
|
private |
Definition at line 211 of file RpcServer.cpp.
Referenced by handleHello(), and setManifest().
|
private |
Definition at line 208 of file RpcServer.cpp.
Referenced by handleHello(), and setManifest().
|
private |
Definition at line 220 of file RpcServer.cpp.
Referenced by handleHello(), registerReadPort(), and registerWritePort().
|
private |
Definition at line 225 of file RpcServer.cpp.
Referenced by onOpen().
|
private |
Definition at line 216 of file RpcServer.cpp.
Referenced by registerReadPort(), retireSession(), and stop().
| utils::ReadyIdSet<uint64_t> esi::cosim::RpcServer::Impl::readyIds |
Definition at line 152 of file RpcServer.cpp.
Referenced by handleSubscribe(), stop(), and transportLoop().
|
private |
Definition at line 247 of file RpcServer.cpp.
|
private |
Definition at line 224 of file RpcServer.cpp.
Referenced by getSession(), onClose(), onOpen(), and stop().
|
private |
Definition at line 223 of file RpcServer.cpp.
Referenced by getSession(), onClose(), onOpen(), and stop().
|
private |
Definition at line 244 of file RpcServer.cpp.
|
private |
Definition at line 217 of file RpcServer.cpp.
Referenced by registerWritePort(), retireSession(), and stop().