|
Motion Master
|
WebSocket server for Motion Master Proto (Protocol Buffer) messages. More...
#include <proto_server.h>
Classes | |
| struct | ConnectionData |
| Per-connection data for each WebSocket. More... | |
Public Member Functions | |
| ProtoServer (mm::core::containers::ThreadSafeQueue< IncomingMachineMessage > &incomingMachineMessageQueue, mm::core::containers::ThreadSafeQueue< OutgoingMachineMessage > &outgoingMachineMessageQueue, uint16_t reqResPort=63524, uint16_t pubSubPort=63525) | |
| Construct a new ProtoServer object. | |
| ~ProtoServer () | |
| Destructor for ProtoServer. | |
| void | start () |
| Starts the ProtoServer by launching its main threads. | |
| void | stop () |
| Stops the ProtoServer and performs a clean shutdown. | |
WebSocket server for Motion Master Proto (Protocol Buffer) messages.
Manages two WebSocket servers: one for request/response and one for publish/subscribe communication. Handles connection management, unique connection identification, threading, and event loop control for both server types. Provides thread-safe message queues for incoming and outgoing machine messages.
|
explicit |
Construct a new ProtoServer object.
| incomingMachineMessageQueue | Reference to the thread-safe queue of incoming machine messages. |
| outgoingMachineMessageQueue | Reference to the thread-safe queue of outgoing machine messages. |
| reqResPort | TCP port for REQ/RES WebSocket connections. |
| pubSubPort | TCP port for PUB/SUB WebSocket connections. |
| ProtoServer::~ProtoServer | ( | ) |
Destructor for ProtoServer.
Stops the server and ensures all resources and threads are cleaned up.
| void ProtoServer::start | ( | ) |
Starts the ProtoServer by launching its main threads.
This function launches three threads:
If the server is already running, this function does nothing.
Threads are created using std::thread and run the corresponding event loops. If thread creation fails, the program will terminate with a std::system_error.
| void ProtoServer::stop | ( | ) |
Stops the ProtoServer and performs a clean shutdown.
This function will:
Multiple calls to this function are safe; if the server is already stopped, the function returns immediately.