Class RemoteConnection
Defined in File RemoteConnection.hpp
Class Documentation
-
class RemoteConnection
Runs a websocket server exposing DepthAI messages as well as a static frontend UI.
Public Functions
-
explicit RemoteConnection(const std::string &address = DEFAULT_ADDRESS, uint16_t webSocketPort = DEFAULT_WEBSOCKET_PORT, bool serveFrontend = true, uint16_t httpPort = DEFAULT_HTTP_PORT)
Constructs a RemoteConnection instance.
- Parameters:
address – The address to bind the connection to.
webSocketPort – The port for WebSocket communication.
serveFrontend – Whether to serve a frontend UI.
httpPort – The port for HTTP communication.
-
~RemoteConnection()
Destroys the RemoteConnection instance.
-
void addTopic(const std::string &topicName, Node::Output &output, const std::string &group = "", bool useVisualizationIfAvailable = true)
Adds a topic to the remote connection.
- Parameters:
topicName – The name of the topic.
output – The output to link to the topic.
group – An optional group name for the topic.
useVisualizationIfAvailable – Whether to enable visualization on the message if available or send message as is.
-
std::shared_ptr<MessageQueue> addTopic(const std::string &topicName, const std::string &group = "", unsigned int maxSize = 16, bool blocking = false, bool useVisualizationIfAvailable = true)
Adds a topic with a message queue.
- Parameters:
topicName – The name of the topic.
group – An optional group name for the topic.
maxSize – The maximum queue size.
blocking – Whether the queue is blocking or non-blocking.
useVisualizationIfAvailable – Whether to enable visualization on the message if available or send message as is.
- Returns:
A shared pointer to the created message queue.
-
bool removeTopic(const std::string &topicName)
Removes a topic from the remote connection.
Note
After removing a topic any messages sent to it will cause an exception to be called on the sender, since this closes the queue.
- Parameters:
topicName – The name of the topic to remove.
- Returns:
True if the topic was successfully removed, false otherwise.
-
void registerPipeline(const Pipeline &pipeline)
Registers a pipeline with the remote connection.
- Parameters:
pipeline – The pipeline to register.
-
int waitKey(int delayMs)
Waits for a key event.
- Parameters:
delayMs – The delay in milliseconds to wait for a key press.
- Returns:
The key code of the pressed key.
-
void registerService(const std::string &serviceName, std::function<nlohmann::json(const nlohmann::json&)> callback)
Registers a service with a callback function.
- Parameters:
serviceName – The name of the service.
callback – The callback function to handle requests.
-
explicit RemoteConnection(const std::string &address = DEFAULT_ADDRESS, uint16_t webSocketPort = DEFAULT_WEBSOCKET_PORT, bool serveFrontend = true, uint16_t httpPort = DEFAULT_HTTP_PORT)