Allolib  1.0
C++ Components For Interactive Multimedia
al::CommandServer Class Reference
Inheritance diagram for al::CommandServer:
al::CommandConnection

Public Types

enum  InternalCommands {
  HANDSHAKE = 1 , HANDSHAKE_ACK , GOODBYE , GOODBYE_ACK ,
  PING , PONG , COMMAND_QUIT , COMMAND_LAST_INTERNAL = 32
}
 

Public Member Functions

bool start (uint16_t serverPort=34450, const char *serverAddr="localhost") override
 
void stop () override
 
uint16_t waitForConnections (uint16_t connectionCount, double timeout=60.0)
 Block until connectionCount connections are established. More...
 
std::vector< float > ping (double timeoutSecs=1.0)
 Wait for timeoutSecs for reply from all. More...
 
size_t connectionCount ()
 
std::vector< std::pair< std::string, uint16_t > > connections ()
 
bool sendMessage (uint8_t *message, size_t length, Socket *dst=nullptr, ValueSource *src=nullptr) override
 sendMessage More...
 
virtual bool processIncomingMessage (Message &message, Socket *src)
 
virtual void onReceiveError ()
 
void setVerbose (bool verbose)
 

Protected Types

enum  BarrierState { SERVER , CLIENT , NONE }
 

Protected Member Functions

virtual void onConnection (Socket *newConnection)
 

Protected Attributes

uint16_t mVersion = 0
 
uint16_t mRevision = 0
 
BarrierState mState {BarrierState::NONE}
 
std::mutex mConnectionsLock
 
bool mRunning {false}
 
std::vector< std::unique_ptr< std::thread > > mConnectionThreads
 
std::vector< std::unique_ptr< std::thread > > mDataThreads
 
std::vector< std::shared_ptr< al::Socket > > mServerConnections
 
std::vector< std::pair< uint16_t, uint16_t > > mConnectionVersions
 
al::Socket mSocket
 
bool mVerbose {false}
 

Detailed Description

Definition at line 209 of file al_CommandConnection.hpp.

Member Function Documentation

◆ ping()

std::vector<float> al::CommandServer::ping ( double  timeoutSecs = 1.0)

Wait for timeoutSecs for reply from all.

Parameters
timeoutSecs
Returns
ping time for each connection. If time > timeout no ping received

If timeout is 0, this function blocks until all replies are received

◆ sendMessage()

bool al::CommandServer::sendMessage ( uint8_t *  message,
size_t  length,
Socket dst = nullptr,
ValueSource src = nullptr 
)
overridevirtual

sendMessage

Parameters
message
dst
Returns

if dst is nullptr, the message is sent to all registered sockets

Reimplemented from al::CommandConnection.

◆ waitForConnections()

uint16_t al::CommandServer::waitForConnections ( uint16_t  connectionCount,
double  timeout = 60.0 
)

Block until connectionCount connections are established.

Returns
number of connections acquired during wait

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