CppServer
1.0.0.0
C++ Server Library
|
#include <bus.h>
Public Member Functions | |
Bus (const std::string &address, bool threading=true) | |
Initialize bus node with a given endpoint address. More... | |
Bus (const Bus &)=delete | |
Bus (Bus &&)=default | |
virtual | ~Bus ()=default |
Bus & | operator= (const Bus &)=delete |
Bus & | operator= (Bus &&)=default |
bool | Link (const std::string &address) |
Link the current bus node to another one. More... | |
![]() | |
Server (Domain domain, Protocol protocol, const std::string &address, bool threading=true) | |
Initialize server with a given domain, protocol and endpoint address. More... | |
Server (const Server &)=delete | |
Server (Server &&)=default | |
virtual | ~Server () |
Server & | operator= (const Server &)=delete |
Server & | operator= (Server &&)=default |
Socket & | socket () noexcept |
Get the Nanomsg socket. More... | |
bool | IsStarted () const noexcept |
Is the server started? More... | |
bool | Start () |
Start the server. More... | |
bool | Stop () |
Stop the server. More... | |
bool | Restart () |
Restart the server. More... | |
size_t | Send (const void *buffer, size_t size) |
Send data to the client. More... | |
size_t | Send (const std::string &text) |
Send a text string to the client. More... | |
size_t | Send (const Message &message) |
Send a message to the client. More... | |
size_t | TrySend (const void *buffer, size_t size) |
Try to send data to the client in non-blocking mode. More... | |
size_t | TrySend (const std::string &text) |
Try to send a text string to the client in non-blocking mode. More... | |
size_t | TrySend (const Message &message) |
Try to send a message to the client in non-blocking mode. More... | |
size_t | Receive (Message &message) |
Receive a message from the client. More... | |
size_t | TryReceive (Message &message) |
Try to receive a message from the client in non-blocking mode. More... | |
Additional Inherited Members | |
![]() | |
virtual void | onThreadInitialize () |
Initialize thread handler. More... | |
virtual void | onThreadCleanup () |
Cleanup thread handler. More... | |
virtual void | onStarted () |
Handle server started notification. More... | |
virtual void | onStopped () |
Handle server stopped notification. More... | |
virtual void | onIdle () |
Handle server idle notification. More... | |
virtual void | onReceived (Message &message) |
Handle message received notification. More... | |
virtual void | onError (int error, const std::string &message) |
Handle error notification. More... | |
Nanomsg bus node.
Nanomsg bus node is used to perform a duplex communication with other Nanomsg bus nodes.
Broadcasts messages from any node to all other nodes in the topology. The server should never receive messages that it sent itself.
This pattern scales only to local level (within a single machine or within a single LAN). Trying to scale it further can result in overloading individual nodes with messages.
Sent messages are distributed to all nodes in the topology. Incoming messages from all other nodes in the topology are fair-queued in the server.
Warning: For bus topology to function correctly, user is responsible for ensuring that path from each node to any other node exists within the topology.
Thread-safe.
|
inlineexplicit |
Initialize bus node with a given endpoint address.
address | - Endpoint address |
threading | - Run the bus node in a separate thread (default is true) |
|
delete |
|
default |
|
virtualdefault |
bool CppServer::Nanomsg::Bus::Link | ( | const std::string & | address | ) |
Link the current bus node to another one.
The address argument consists of two parts as follows: transport://address. The transport specifies the underlying transport protocol to use. The meaning of the address part is specific to the underlying transport protocol.
address | - Endpoint address |