CppServer  1.0.0.0
C++ Server Library
survey_server.cpp
Go to the documentation of this file.
1 
10 
11 namespace CppServer {
12 namespace Nanomsg {
13 
14 std::tuple<size_t, bool> SurveyServer::ReceiveSurvey(Message& message)
15 {
16  if (!IsStarted())
17  return std::make_tuple(0, true);
18 
19  try
20  {
21  return socket().ReceiveSurvey(message);
22  }
23  catch (CppCommon::SystemException& ex)
24  {
25  onError(ex.system_error(), ex.string());
26  return std::make_tuple(0, true);
27  }
28 }
29 
30 std::tuple<size_t, bool> SurveyServer::TryReceiveSurvey(Message& message)
31 {
32  if (!IsStarted())
33  return std::make_tuple(0, true);
34 
35  try
36  {
37  return socket().TryReceiveSurvey(message);
38  }
39  catch (CppCommon::SystemException& ex)
40  {
41  onError(ex.system_error(), ex.string());
42  return std::make_tuple(0, true);
43  }
44 }
45 
46 } // namespace Nanomsg
47 } // namespace CppServer
Nanomsg message.
Definition: message.h:29
std::tuple< size_t, bool > ReceiveSurvey(Message &message)
Receive a respond to the survey from the socket in non-blocking mode.
Definition: socket.cpp:351
Socket & socket() noexcept
Get the Nanomsg socket.
Definition: server.h:48
C++ Server project definitions.
Definition: asio.h:24
std::tuple< size_t, bool > TryReceiveSurvey(Message &message)
Try to receive a respond to the survey from the socket in non-blocking mode.
Definition: socket.cpp:379
std::tuple< size_t, bool > ReceiveSurvey(Message &message)
Receive a respond to the survey from the clients in non-blocking mode.
Nanomsg survey server definition.
bool IsStarted() const noexcept
Is the server started?
Definition: server.h:51
virtual void onError(int error, const std::string &message)
Handle error notification.
Definition: server.h:154
std::tuple< size_t, bool > TryReceiveSurvey(Message &message)
Try to receive a respond to the survey from the clients in non-blocking mode.