CIRCT 23.0.0git
Loading...
Searching...
No Matches
Classes | Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
esi::cosim::RpcServer::Impl Class Reference
Collaboration diagram for esi::cosim::RpcServer::Impl:
Collaboration graph
[legend]

Classes

struct  ChannelInfo
 
struct  ClientSession
 

Public Member Functions

 Impl (Context &ctxt, int port)
 
 ~Impl ()
 
ContextgetContext ()
 
void setManifest (int esiVersion, const std::vector< uint8_t > &compressedManifest)
 
ReadChannelPortregisterReadPort (const std::string &name, const std::string &type)
 
WriteChannelPortregisterWritePort (const std::string &name, const std::string &type)
 
void stop (uint32_t timeoutMS)
 
int getPort () const
 

Public Attributes

utils::ReadyIdSet< uint64_t > readyIds
 

Private Types

using ChannelDirection = backends::cosim::RpcClient::ChannelDirection
 

Private Member Functions

void onClientMessage (std::shared_ptr< ix::ConnectionState > state, ix::WebSocket &ws, const ix::WebSocketMessagePtr &msg)
 
void onOpen (ix::WebSocket &ws)
 
void onClose ()
 
void handleBinaryFrame (const std::string &data)
 
void handleControlFrame (ix::WebSocket &ws, const std::string &text)
 
void handleHello (ix::WebSocket &ws, uint64_t requestId, const json &params)
 
void handleSubscribe (ix::WebSocket &ws, uint64_t requestId, const json &params)
 
void handleUnsubscribe (ix::WebSocket &ws, uint64_t requestId, const json &params)
 
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 ()
 

Private Attributes

Contextctxt
 
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, ChannelInfochannelById
 
std::unordered_map< std::string, uint64_t > idByName
 
uint64_t nextChannelId = 0
 
std::mutex sessionMutex
 
std::unique_ptr< ClientSessionsession
 
std::thread transportThread
 
std::unique_ptr< ix::WebSocketServer > server
 
int boundPort = -1
 
::esi::cosim::FaultStash faultStash
 

Detailed Description

Definition at line 126 of file RpcServer.cpp.

Member Typedef Documentation

◆ ChannelDirection

Definition at line 154 of file RpcServer.cpp.

Constructor & Destructor Documentation

◆ Impl()

Impl::Impl ( Context ctxt,
int  port 
)

◆ ~Impl()

Impl::~Impl ( )

Definition at line 345 of file RpcServer.cpp.

References ctxt, esi::Logger::error(), esi::Context::getLogger(), server, and stop().

Member Function Documentation

◆ getContext()

Context & esi::cosim::RpcServer::Impl::getContext ( )
inline

Definition at line 131 of file RpcServer.cpp.

References ctxt.

◆ getPort()

int esi::cosim::RpcServer::Impl::getPort ( ) const
inline

Definition at line 142 of file RpcServer.cpp.

References boundPort.

◆ handleBinaryFrame()

void Impl::handleBinaryFrame ( const std::string &  data)
private

◆ handleControlFrame()

void Impl::handleControlFrame ( ix::WebSocket &  ws,
const std::string &  text 
)
private

◆ handleHello()

void Impl::handleHello ( ix::WebSocket &  ws,
uint64_t  requestId,
const json params 
)
private

◆ handleSubscribe()

void Impl::handleSubscribe ( ix::WebSocket &  ws,
uint64_t  requestId,
const json params 
)
private

◆ handleUnsubscribe()

void Impl::handleUnsubscribe ( ix::WebSocket &  ws,
uint64_t  requestId,
const json params 
)
private

Definition at line 702 of file RpcServer.cpp.

References sendError(), sendResult(), session, and sessionMutex.

Referenced by handleControlFrame().

◆ onClientMessage()

void Impl::onClientMessage ( std::shared_ptr< ix::ConnectionState >  state,
ix::WebSocket &  ws,
const ix::WebSocketMessagePtr &  msg 
)
private

◆ onClose()

void Impl::onClose ( )
private

Definition at line 501 of file RpcServer.cpp.

References session, and sessionMutex.

Referenced by onClientMessage().

◆ onOpen()

void esi::cosim::RpcServer::Impl::onOpen ( ix::WebSocket &  ws)
private

◆ registerReadPort()

ReadChannelPort & Impl::registerReadPort ( const std::string &  name,
const std::string &  type 
)

◆ registerWritePort()

WriteChannelPort & Impl::registerWritePort ( const std::string &  name,
const std::string &  type 
)

◆ sendError()

void Impl::sendError ( ix::WebSocket &  ws,
uint64_t  requestId,
const std::string &  code,
const std::string &  message 
)
private

Definition at line 739 of file RpcServer.cpp.

Referenced by handleControlFrame(), handleSubscribe(), and handleUnsubscribe().

◆ sendResult()

void Impl::sendResult ( ix::WebSocket &  ws,
uint64_t  requestId,
const json result 
)
private

Definition at line 727 of file RpcServer.cpp.

Referenced by handleHello(), handleSubscribe(), and handleUnsubscribe().

◆ setManifest()

void Impl::setManifest ( int  esiVersion,
const std::vector< uint8_t > &  compressedManifest 
)

◆ stop()

void Impl::stop ( uint32_t  timeoutMS)

◆ transportLoop()

void Impl::transportLoop ( )
private

Member Data Documentation

◆ boundPort

int esi::cosim::RpcServer::Impl::boundPort = -1
private

Definition at line 201 of file RpcServer.cpp.

Referenced by getPort(), and Impl().

◆ channelById

std::unordered_map<uint64_t, ChannelInfo> esi::cosim::RpcServer::Impl::channelById
private

◆ channelsMutex

std::mutex esi::cosim::RpcServer::Impl::channelsMutex
private

◆ compressedManifest

std::vector<uint8_t> esi::cosim::RpcServer::Impl::compressedManifest
private

Definition at line 180 of file RpcServer.cpp.

Referenced by handleHello(), and setManifest().

◆ ctxt

Context& esi::cosim::RpcServer::Impl::ctxt
private

◆ esiVersion

int esi::cosim::RpcServer::Impl::esiVersion = -1
private

Definition at line 179 of file RpcServer.cpp.

Referenced by handleHello(), and setManifest().

◆ faultStash

::esi::cosim::FaultStash esi::cosim::RpcServer::Impl::faultStash
private

◆ idByName

std::unordered_map<std::string, uint64_t> esi::cosim::RpcServer::Impl::idByName
private

Definition at line 189 of file RpcServer.cpp.

Referenced by registerReadPort(), and registerWritePort().

◆ manifestMutex

std::mutex esi::cosim::RpcServer::Impl::manifestMutex
private

Definition at line 177 of file RpcServer.cpp.

Referenced by handleHello(), and setManifest().

◆ manifestReady

bool esi::cosim::RpcServer::Impl::manifestReady = false
private

Definition at line 181 of file RpcServer.cpp.

Referenced by handleHello(), and setManifest().

◆ manifestReadyCV

std::condition_variable esi::cosim::RpcServer::Impl::manifestReadyCV
private

Definition at line 178 of file RpcServer.cpp.

Referenced by handleHello(), and setManifest().

◆ nextChannelId

uint64_t esi::cosim::RpcServer::Impl::nextChannelId = 0
private

Definition at line 190 of file RpcServer.cpp.

Referenced by handleHello(), registerReadPort(), and registerWritePort().

◆ readPorts

std::map<std::string, std::unique_ptr<RpcServerReadPort> > esi::cosim::RpcServer::Impl::readPorts
private

Definition at line 186 of file RpcServer.cpp.

Referenced by registerReadPort(), and stop().

◆ readyIds

utils::ReadyIdSet<uint64_t> esi::cosim::RpcServer::Impl::readyIds

Definition at line 148 of file RpcServer.cpp.

Referenced by handleSubscribe(), stop(), and transportLoop().

◆ server

std::unique_ptr<ix::WebSocketServer> esi::cosim::RpcServer::Impl::server
private

Definition at line 200 of file RpcServer.cpp.

Referenced by Impl(), stop(), and ~Impl().

◆ session

std::unique_ptr<ClientSession> esi::cosim::RpcServer::Impl::session
private

◆ sessionMutex

std::mutex esi::cosim::RpcServer::Impl::sessionMutex
private

◆ transportThread

std::thread esi::cosim::RpcServer::Impl::transportThread
private

Definition at line 197 of file RpcServer.cpp.

Referenced by Impl(), and stop().

◆ writePorts

std::map<std::string, std::unique_ptr<RpcServerWritePort> > esi::cosim::RpcServer::Impl::writePorts
private

Definition at line 187 of file RpcServer.cpp.

Referenced by registerWritePort(), and stop().


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