Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
foxglove::Server< ServerConfiguration > Class Template Referencefinal

#include <websocket_server.hpp>

Inheritance diagram for foxglove::Server< ServerConfiguration >:
Inheritance graph
[legend]

Classes

struct  ClientInfo
 

Public Types

using ConnectionType = websocketpp::connection< ServerConfiguration >
 
using MessagePtr = typename ServerType::message_ptr
 
using ServerType = websocketpp::server< ServerConfiguration >
 
using Tcp = websocketpp::lib::asio::ip::tcp
 

Public Member Functions

std::vector< ChannelIdaddChannels (const std::vector< ChannelWithoutId > &channels) override
 
std::vector< ServiceIdaddServices (const std::vector< ServiceWithoutId > &services) override
 
void broadcastTime (uint64_t timestamp) override
 
uint16_t getPort () override
 
Serveroperator= (const Server &)=delete
 
Serveroperator= (Server &&)=delete
 
void publishParameterValues (ConnHandle clientHandle, const std::vector< Parameter > &parameters, const std::optional< std::string > &requestId=std::nullopt) override
 
std::string remoteEndpointString (ConnHandle clientHandle) override
 
void removeChannels (const std::vector< ChannelId > &channelIds) override
 
void removeServices (const std::vector< ServiceId > &serviceIds) override
 
void sendMessage (ConnHandle clientHandle, ChannelId chanId, uint64_t timestamp, const uint8_t *payload, size_t payloadSize) override
 
void sendServiceResponse (ConnHandle clientHandle, const ServiceResponse &response) override
 
 Server (std::string name, LogCallback logger, const ServerOptions &options)
 
 Server (const Server &)=delete
 
 Server (Server &&)=delete
 
void setHandlers (ServerHandlers< ConnHandle > &&handlers) override
 
void start (const std::string &host, uint16_t port) override
 
void stop () override
 
void updateConnectionGraph (const MapOfSets &publishedTopics, const MapOfSets &subscribedTopics, const MapOfSets &advertisedServices) override
 
void updateParameterValues (const std::vector< Parameter > &parameters) override
 
virtual ~Server ()
 
- Public Member Functions inherited from foxglove::ServerInterface< ConnHandle >
virtual ~ServerInterface ()
 

Private Member Functions

void handleBinaryMessage (ConnHandle hdl, MessagePtr msg)
 
void handleConnectionClosed (ConnHandle hdl)
 
void handleConnectionOpened (ConnHandle hdl)
 
void handleMessage (ConnHandle hdl, MessagePtr msg)
 
void handleTextMessage (ConnHandle hdl, MessagePtr msg)
 
bool hasCapability (const std::string &capability) const
 
bool isParameterSubscribed (const std::string &paramName) const
 
void sendBinary (ConnHandle hdl, const uint8_t *payload, size_t payloadSize)
 
void sendJson (ConnHandle hdl, json &&payload)
 
void sendJsonRaw (ConnHandle hdl, const std::string &payload)
 
void sendStatusAndLogMsg (ConnHandle clientHandle, const StatusLevel level, const std::string &message)
 
template<>
void setupTlsHandler ()
 
template<>
void setupTlsHandler ()
 
void setupTlsHandler ()
 
void socketInit (ConnHandle hdl)
 
void unsubscribeParamsWithoutSubscriptions (ConnHandle hdl, const std::unordered_set< std::string > &paramNames)
 
bool validateConnection (ConnHandle hdl)
 

Private Attributes

std::unordered_map< ChannelId, Channel_channels
 
std::shared_mutex _channelsMutex
 
std::map< ConnHandle, std::unordered_map< ClientChannelId, ClientAdvertisement >, std::owner_less<> > _clientChannels
 
std::shared_mutex _clientChannelsMutex
 
std::map< ConnHandle, std::unordered_set< std::string >, std::owner_less<> > _clientParamSubscriptions
 
std::mutex _clientParamSubscriptionsMutex
 
std::map< ConnHandle, ClientInfo, std::owner_less<> > _clients
 
std::shared_mutex _clientsMutex
 
struct {
   MapOfSets   advertisedServices
 
   MapOfSets   publishedTopics
 
   MapOfSets   subscribedTopics
 
   int   subscriptionCount = 0
 
_connectionGraph
 
std::shared_mutex _connectionGraphMutex
 
std::unique_ptr< CallbackQueue_handlerCallbackQueue
 
ServerHandlers< ConnHandle_handlers
 
LogCallback _logger
 
std::string _name
 
uint32_t _nextChannelId = 0
 
ServiceId _nextServiceId = 0
 
ServerOptions _options
 
ServerType _server
 
std::unique_ptr< std::thread > _serverThread
 
std::unordered_map< ServiceId, ServiceWithoutId_services
 
std::shared_mutex _servicesMutex
 

Detailed Description

template<typename ServerConfiguration>
class foxglove::Server< ServerConfiguration >

Definition at line 100 of file websocket_server.hpp.

Member Typedef Documentation

◆ ConnectionType

template<typename ServerConfiguration >
using foxglove::Server< ServerConfiguration >::ConnectionType = websocketpp::connection<ServerConfiguration>

Definition at line 103 of file websocket_server.hpp.

◆ MessagePtr

template<typename ServerConfiguration >
using foxglove::Server< ServerConfiguration >::MessagePtr = typename ServerType::message_ptr

Definition at line 104 of file websocket_server.hpp.

◆ ServerType

template<typename ServerConfiguration >
using foxglove::Server< ServerConfiguration >::ServerType = websocketpp::server<ServerConfiguration>

Definition at line 102 of file websocket_server.hpp.

◆ Tcp

template<typename ServerConfiguration >
using foxglove::Server< ServerConfiguration >::Tcp = websocketpp::lib::asio::ip::tcp

Definition at line 105 of file websocket_server.hpp.

Constructor & Destructor Documentation

◆ Server() [1/3]

template<typename ServerConfiguration >
foxglove::Server< ServerConfiguration >::Server ( std::string  name,
LogCallback  logger,
const ServerOptions options 
)
inlineexplicit

Definition at line 209 of file websocket_server.hpp.

◆ ~Server()

template<typename ServerConfiguration >
foxglove::Server< ServerConfiguration >::~Server ( )
inlinevirtual

Definition at line 242 of file websocket_server.hpp.

◆ Server() [2/3]

template<typename ServerConfiguration >
foxglove::Server< ServerConfiguration >::Server ( const Server< ServerConfiguration > &  )
delete

◆ Server() [3/3]

template<typename ServerConfiguration >
foxglove::Server< ServerConfiguration >::Server ( Server< ServerConfiguration > &&  )
delete

Member Function Documentation

◆ addChannels()

template<typename ServerConfiguration >
std::vector< ChannelId > foxglove::Server< ServerConfiguration >::addChannels ( const std::vector< ChannelWithoutId > &  channels)
inlineoverridevirtual

Implements foxglove::ServerInterface< ConnHandle >.

Definition at line 1017 of file websocket_server.hpp.

◆ addServices()

template<typename ServerConfiguration >
std::vector< ServiceId > foxglove::Server< ServerConfiguration >::addServices ( const std::vector< ServiceWithoutId > &  services)
inlineoverridevirtual

Implements foxglove::ServerInterface< ConnHandle >.

Definition at line 1114 of file websocket_server.hpp.

◆ broadcastTime()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::broadcastTime ( uint64_t  timestamp)
inlineoverridevirtual

Implements foxglove::ServerInterface< ConnHandle >.

Definition at line 1213 of file websocket_server.hpp.

◆ getPort()

template<typename ServerConfiguration >
uint16_t foxglove::Server< ServerConfiguration >::getPort ( )
inlineoverridevirtual

Implements foxglove::ServerInterface< ConnHandle >.

Definition at line 1235 of file websocket_server.hpp.

◆ handleBinaryMessage()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::handleBinaryMessage ( ConnHandle  hdl,
MessagePtr  msg 
)
inlineprivate

Definition at line 916 of file websocket_server.hpp.

◆ handleConnectionClosed()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::handleConnectionClosed ( ConnHandle  hdl)
inlineprivate

Definition at line 317 of file websocket_server.hpp.

◆ handleConnectionOpened()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::handleConnectionOpened ( ConnHandle  hdl)
inlineprivate

Definition at line 270 of file websocket_server.hpp.

◆ handleMessage()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::handleMessage ( ConnHandle  hdl,
MessagePtr  msg 
)
inlineprivate

Definition at line 553 of file websocket_server.hpp.

◆ handleTextMessage()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::handleTextMessage ( ConnHandle  hdl,
MessagePtr  msg 
)
inlineprivate

Definition at line 592 of file websocket_server.hpp.

◆ hasCapability()

template<typename ServerConfiguration >
bool foxglove::Server< ServerConfiguration >::hasCapability ( const std::string &  capability) const
inlineprivate

Definition at line 1369 of file websocket_server.hpp.

◆ isParameterSubscribed()

template<typename ServerConfiguration >
bool foxglove::Server< ServerConfiguration >::isParameterSubscribed ( const std::string &  paramName) const
inlineprivate

Definition at line 1331 of file websocket_server.hpp.

◆ operator=() [1/2]

template<typename ServerConfiguration >
Server& foxglove::Server< ServerConfiguration >::operator= ( const Server< ServerConfiguration > &  )
delete

◆ operator=() [2/2]

template<typename ServerConfiguration >
Server& foxglove::Server< ServerConfiguration >::operator= ( Server< ServerConfiguration > &&  )
delete

◆ publishParameterValues()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::publishParameterValues ( ConnHandle  clientHandle,
const std::vector< Parameter > &  parameters,
const std::optional< std::string > &  requestId = std::nullopt 
)
inlineoverridevirtual

Implements foxglove::ServerInterface< ConnHandle >.

Definition at line 1076 of file websocket_server.hpp.

◆ remoteEndpointString()

template<typename ServerConfiguration >
std::string foxglove::Server< ServerConfiguration >::remoteEndpointString ( ConnHandle  clientHandle)
inlineoverridevirtual

Implements foxglove::ServerInterface< ConnHandle >.

Definition at line 1324 of file websocket_server.hpp.

◆ removeChannels()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::removeChannels ( const std::vector< ChannelId > &  channelIds)
inlineoverridevirtual

Implements foxglove::ServerInterface< ConnHandle >.

Definition at line 1049 of file websocket_server.hpp.

◆ removeServices()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::removeServices ( const std::vector< ServiceId > &  serviceIds)
inlineoverridevirtual

Implements foxglove::ServerInterface< ConnHandle >.

Definition at line 1141 of file websocket_server.hpp.

◆ sendBinary()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::sendBinary ( ConnHandle  hdl,
const uint8_t *  payload,
size_t  payloadSize 
)
inlineprivate

Definition at line 526 of file websocket_server.hpp.

◆ sendJson()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::sendJson ( ConnHandle  hdl,
json &&  payload 
)
inlineprivate

Definition at line 508 of file websocket_server.hpp.

◆ sendJsonRaw()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::sendJsonRaw ( ConnHandle  hdl,
const std::string &  payload 
)
inlineprivate

Definition at line 517 of file websocket_server.hpp.

◆ sendMessage()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::sendMessage ( ConnHandle  clientHandle,
ChannelId  chanId,
uint64_t  timestamp,
const uint8_t *  payload,
size_t  payloadSize 
)
inlineoverridevirtual

Implements foxglove::ServerInterface< ConnHandle >.

Definition at line 1163 of file websocket_server.hpp.

◆ sendServiceResponse()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::sendServiceResponse ( ConnHandle  clientHandle,
const ServiceResponse response 
)
inlineoverridevirtual

Implements foxglove::ServerInterface< ConnHandle >.

Definition at line 1226 of file websocket_server.hpp.

◆ sendStatusAndLogMsg()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::sendStatusAndLogMsg ( ConnHandle  clientHandle,
const StatusLevel  level,
const std::string &  message 
)
inlineprivate

Definition at line 536 of file websocket_server.hpp.

◆ setHandlers()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::setHandlers ( ServerHandlers< ConnHandle > &&  handlers)
inlineoverridevirtual

Implements foxglove::ServerInterface< ConnHandle >.

Definition at line 384 of file websocket_server.hpp.

◆ setupTlsHandler() [1/3]

template<>
void foxglove::Server< WebSocketNoTls >::setupTlsHandler ( )
inlineprivate

Definition at line 24 of file server_factory.cpp.

◆ setupTlsHandler() [2/3]

template<>
void foxglove::Server< WebSocketTls >::setupTlsHandler ( )
inlineprivate

Definition at line 29 of file server_factory.cpp.

◆ setupTlsHandler() [3/3]

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::setupTlsHandler ( )
private

◆ socketInit()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::socketInit ( ConnHandle  hdl)
inlineprivate

Definition at line 245 of file websocket_server.hpp.

◆ start()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::start ( const std::string &  host,
uint16_t  port 
)
inlineoverridevirtual

Implements foxglove::ServerInterface< ConnHandle >.

Definition at line 467 of file websocket_server.hpp.

◆ stop()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::stop ( )
inlineoverridevirtual

Implements foxglove::ServerInterface< ConnHandle >.

Definition at line 389 of file websocket_server.hpp.

◆ unsubscribeParamsWithoutSubscriptions()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::unsubscribeParamsWithoutSubscriptions ( ConnHandle  hdl,
const std::unordered_set< std::string > &  paramNames 
)
inlineprivate

Definition at line 1340 of file websocket_server.hpp.

◆ updateConnectionGraph()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::updateConnectionGraph ( const MapOfSets publishedTopics,
const MapOfSets subscribedTopics,
const MapOfSets advertisedServices 
)
inlineoverridevirtual

Implements foxglove::ServerInterface< ConnHandle >.

Definition at line 1245 of file websocket_server.hpp.

◆ updateParameterValues()

template<typename ServerConfiguration >
void foxglove::Server< ServerConfiguration >::updateParameterValues ( const std::vector< Parameter > &  parameters)
inlineoverridevirtual

Implements foxglove::ServerInterface< ConnHandle >.

Definition at line 1094 of file websocket_server.hpp.

◆ validateConnection()

template<typename ServerConfiguration >
bool foxglove::Server< ServerConfiguration >::validateConnection ( ConnHandle  hdl)
inlineprivate

Definition at line 254 of file websocket_server.hpp.

Member Data Documentation

◆ _channels

template<typename ServerConfiguration >
std::unordered_map<ChannelId, Channel> foxglove::Server< ServerConfiguration >::_channels
private

Definition at line 166 of file websocket_server.hpp.

◆ _channelsMutex

template<typename ServerConfiguration >
std::shared_mutex foxglove::Server< ServerConfiguration >::_channelsMutex
private

Definition at line 175 of file websocket_server.hpp.

◆ _clientChannels

template<typename ServerConfiguration >
std::map<ConnHandle, std::unordered_map<ClientChannelId, ClientAdvertisement>, std::owner_less<> > foxglove::Server< ServerConfiguration >::_clientChannels
private

Definition at line 168 of file websocket_server.hpp.

◆ _clientChannelsMutex

template<typename ServerConfiguration >
std::shared_mutex foxglove::Server< ServerConfiguration >::_clientChannelsMutex
private

Definition at line 176 of file websocket_server.hpp.

◆ _clientParamSubscriptions

template<typename ServerConfiguration >
std::map<ConnHandle, std::unordered_set<std::string>, std::owner_less<> > foxglove::Server< ServerConfiguration >::_clientParamSubscriptions
private

Definition at line 170 of file websocket_server.hpp.

◆ _clientParamSubscriptionsMutex

template<typename ServerConfiguration >
std::mutex foxglove::Server< ServerConfiguration >::_clientParamSubscriptionsMutex
private

Definition at line 178 of file websocket_server.hpp.

◆ _clients

template<typename ServerConfiguration >
std::map<ConnHandle, ClientInfo, std::owner_less<> > foxglove::Server< ServerConfiguration >::_clients
private

Definition at line 165 of file websocket_server.hpp.

◆ _clientsMutex

template<typename ServerConfiguration >
std::shared_mutex foxglove::Server< ServerConfiguration >::_clientsMutex
private

Definition at line 174 of file websocket_server.hpp.

◆ _connectionGraph

struct { ... } foxglove::Server< ServerConfiguration >::_connectionGraph

◆ _connectionGraphMutex

template<typename ServerConfiguration >
std::shared_mutex foxglove::Server< ServerConfiguration >::_connectionGraphMutex
private

Definition at line 186 of file websocket_server.hpp.

◆ _handlerCallbackQueue

template<typename ServerConfiguration >
std::unique_ptr<CallbackQueue> foxglove::Server< ServerConfiguration >::_handlerCallbackQueue
private

Definition at line 162 of file websocket_server.hpp.

◆ _handlers

template<typename ServerConfiguration >
ServerHandlers<ConnHandle> foxglove::Server< ServerConfiguration >::_handlers
private

Definition at line 173 of file websocket_server.hpp.

◆ _logger

template<typename ServerConfiguration >
LogCallback foxglove::Server< ServerConfiguration >::_logger
private

Definition at line 158 of file websocket_server.hpp.

◆ _name

template<typename ServerConfiguration >
std::string foxglove::Server< ServerConfiguration >::_name
private

Definition at line 157 of file websocket_server.hpp.

◆ _nextChannelId

template<typename ServerConfiguration >
uint32_t foxglove::Server< ServerConfiguration >::_nextChannelId = 0
private

Definition at line 164 of file websocket_server.hpp.

◆ _nextServiceId

template<typename ServerConfiguration >
ServiceId foxglove::Server< ServerConfiguration >::_nextServiceId = 0
private

Definition at line 171 of file websocket_server.hpp.

◆ _options

template<typename ServerConfiguration >
ServerOptions foxglove::Server< ServerConfiguration >::_options
private

Definition at line 159 of file websocket_server.hpp.

◆ _server

template<typename ServerConfiguration >
ServerType foxglove::Server< ServerConfiguration >::_server
private

Definition at line 160 of file websocket_server.hpp.

◆ _serverThread

template<typename ServerConfiguration >
std::unique_ptr<std::thread> foxglove::Server< ServerConfiguration >::_serverThread
private

Definition at line 161 of file websocket_server.hpp.

◆ _services

template<typename ServerConfiguration >
std::unordered_map<ServiceId, ServiceWithoutId> foxglove::Server< ServerConfiguration >::_services
private

Definition at line 172 of file websocket_server.hpp.

◆ _servicesMutex

template<typename ServerConfiguration >
std::shared_mutex foxglove::Server< ServerConfiguration >::_servicesMutex
private

Definition at line 177 of file websocket_server.hpp.

◆ advertisedServices

template<typename ServerConfiguration >
MapOfSets foxglove::Server< ServerConfiguration >::advertisedServices

Definition at line 184 of file websocket_server.hpp.

◆ publishedTopics

template<typename ServerConfiguration >
MapOfSets foxglove::Server< ServerConfiguration >::publishedTopics

Definition at line 182 of file websocket_server.hpp.

◆ subscribedTopics

template<typename ServerConfiguration >
MapOfSets foxglove::Server< ServerConfiguration >::subscribedTopics

Definition at line 183 of file websocket_server.hpp.

◆ subscriptionCount

template<typename ServerConfiguration >
int foxglove::Server< ServerConfiguration >::subscriptionCount = 0

Definition at line 181 of file websocket_server.hpp.


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


foxglove_bridge
Author(s): Foxglove
autogenerated on Mon Jul 3 2023 02:12:22