CppServer  1.0.0.0
C++ Server Library
Public Member Functions | List of all members
CppServer::Nanomsg::SurveyServer Class Reference

Nanomsg survey server. More...

#include <survey_server.h>

Inheritance diagram for CppServer::Nanomsg::SurveyServer:
CppServer::Nanomsg::Server

Public Member Functions

 SurveyServer (const std::string &address, int deadline=1000)
 Initialize server with a given endpoint address. More...
 
 SurveyServer (const SurveyServer &)=delete
 
 SurveyServer (SurveyServer &&)=default
 
virtual ~SurveyServer ()=default
 
SurveyServeroperator= (const SurveyServer &)=delete
 
SurveyServeroperator= (SurveyServer &&)=default
 
std::tuple< size_t, bool > ReceiveSurvey (Message &message)
 Receive a respond to the survey from the clients in non-blocking mode. More...
 
std::tuple< size_t, bool > TryReceiveSurvey (Message &message)
 Try to receive a respond to the survey from the clients in non-blocking mode. More...
 
- Public Member Functions inherited from CppServer::Nanomsg::Server
 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 ()
 
Serveroperator= (const Server &)=delete
 
Serveroperator= (Server &&)=default
 
Socketsocket () 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

- Protected Member Functions inherited from CppServer::Nanomsg::Server
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...
 

Detailed Description

Nanomsg survey server.

Nanomsg survey server is used to perform a survey using several connected Nanomsg survey clients.

Used to send the survey. The survey is delivered to all the connected respondents. Once the query is sent, the socket can be used to receive the responses. When the survey deadline expires, receive will return ETIMEDOUT error.

Thread-safe.

Examples:
nanomsg_survey_server.cpp.

Definition at line 29 of file survey_server.h.

Constructor & Destructor Documentation

◆ SurveyServer() [1/3]

CppServer::Nanomsg::SurveyServer::SurveyServer ( const std::string &  address,
int  deadline = 1000 
)
inlineexplicit

Initialize server with a given endpoint address.

Parameters
address- Endpoint address
deadline- Deadline timeout in milliseconds (default is 1000)
Examples:
nanomsg_survey_server.cpp.

Definition at line 37 of file survey_server.h.

◆ SurveyServer() [2/3]

CppServer::Nanomsg::SurveyServer::SurveyServer ( const SurveyServer )
delete

◆ SurveyServer() [3/3]

CppServer::Nanomsg::SurveyServer::SurveyServer ( SurveyServer &&  )
default

◆ ~SurveyServer()

virtual CppServer::Nanomsg::SurveyServer::~SurveyServer ( )
virtualdefault

Member Function Documentation

◆ operator=() [1/2]

SurveyServer& CppServer::Nanomsg::SurveyServer::operator= ( const SurveyServer )
delete

◆ operator=() [2/2]

SurveyServer& CppServer::Nanomsg::SurveyServer::operator= ( SurveyServer &&  )
default

◆ ReceiveSurvey()

std::tuple< size_t, bool > CppServer::Nanomsg::SurveyServer::ReceiveSurvey ( Message message)

Receive a respond to the survey from the clients in non-blocking mode.

Parameters
message- Message to receive
Returns
Count of received bytes and survey complete flag

Definition at line 14 of file survey_server.cpp.

◆ TryReceiveSurvey()

std::tuple< size_t, bool > CppServer::Nanomsg::SurveyServer::TryReceiveSurvey ( Message message)

Try to receive a respond to the survey from the clients in non-blocking mode.

Parameters
message- Message to receive
Returns
Count of received bytes and survey complete flag

Definition at line 30 of file survey_server.cpp.


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