COOLFluiD
Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
|
This class is the server network level. More...
#include <ServerNetworkComm.hpp>
Inherits SignalHandler.
Classes | |
struct | ClientInfo |
Public Member Functions | |
ServerNetworkComm () | |
Constructor. More... | |
~ServerNetworkComm () | |
Destructor. More... | |
bool | open_port (unsigned short port=62784) |
Opens a port the server has to listen to. More... | |
void | run () |
void | close () |
Stops all network operations. More... | |
void | send_message_to_client (const std::string &message, uiCommon::LogMessage::Type type, const std::string &uuid=std::string()) |
Sends a message to a client. More... | |
void | send_frame_to_client (common::XML::SignalFrame &signal, const std::string &uuid=std::string()) |
void | send_frame_rejected_to_client (const std::string clientid, const std::string &frameid, const common::URI &sender, const std::string &reason) |
Public Member Functions inherited from SignalHandler | |
~SignalHandler () | |
const storage_t & | signal_list () const |
SignalPtr | signal (const SignalID &sname) |
SignalCPtr | signal (const SignalID &sname) const |
SignalRet | call_signal (const SignalID &sname, SignalArgs &sinput) |
Calls the signal by providing its name and input. More... | |
SignalRet | call_signal (const SignalID &sname, std::vector< std::string > &sinput) |
Calls the signal by providing its name and input. More... | |
bool | signal_exists (const SignalID &sname) const |
Checks if a signal exists or not. More... | |
Signal & | regist_signal (const SignalID &sname) |
Regist signal. More... | |
void | unregist_signal (const SignalID &sname) |
Unregist signal. More... | |
Private Member Functions | |
void | init_accept () |
void | init_send (boost::shared_ptr< network::TCPConnection > client, common::XML::SignalFrame &frame) |
void | init_read (ClientInfo &client) |
void | callback_accept (boost::shared_ptr< network::TCPConnection > conn, const boost::system::error_code &error) |
void | callback_send (boost::shared_ptr< network::TCPConnection > conn, const boost::system::error_code &error) |
void | callback_read (boost::shared_ptr< network::TCPConnection > conn, const boost::system::error_code &error) |
void | send_message (boost::shared_ptr< network::TCPConnection > client, const std::string &message, uiCommon::LogMessage::Type type) |
Sends a message to a client. More... | |
void | send (boost::shared_ptr< network::TCPConnection > client, const common::XML::XmlDoc &signal) |
Sends a message to a client. More... | |
void | send_frame_rejected (boost::shared_ptr< network::TCPConnection > client, const std::string &frameid, const cf3::common::URI &sender, const std::string &reason) |
boost::shared_ptr< network::TCPConnection > | get_connection (const std::string &uuid) const |
Retrieves a client socket from its UuiD. More... | |
Private Attributes | |
boost::asio::io_service * | m_io_service |
boost::asio::ip::tcp::acceptor * | m_acceptor |
unsigned short | m_port |
std::map< boost::shared_ptr< network::TCPConnection >, ClientInfo > | m_clients |
Mutex for thread-safe operations. More... | |
Additional Inherited Members | |
Public Types inherited from SignalHandler | |
typedef std::vector< SignalPtr > | storage_t |
storage type for signals More... | |
Public Attributes inherited from SignalHandler | |
storage_t | m_signals |
storage of the signals More... | |
This class is the server network level.
For all signals emitted by this class, the first parameter identifies the client that caused the signal to be emitted. A same client will always have the same id. When client disconnects, its id will never be given to another client.
Definition at line 43 of file ServerNetworkComm.hpp.
Constructor.
Definition at line 48 of file ServerNetworkComm.cpp.
~ServerNetworkComm | ( | ) |
Destructor.
Closes the sockets before the object is deleted.
Definition at line 58 of file ServerNetworkComm.cpp.
|
private |
Definition at line 173 of file ServerNetworkComm.cpp.
|
private |
Definition at line 209 of file ServerNetworkComm.cpp.
|
private |
Definition at line 199 of file ServerNetworkComm.cpp.
void close | ( | ) |
Stops all network operations.
Definition at line 93 of file ServerNetworkComm.cpp.
|
private |
Retrieves a client socket from its UuiD.
uuid | Client UuiD |
nullptr
if client UuiD was -1 (all clients). UnknownClientIdException | if Client id is unknown. |
Definition at line 343 of file ServerNetworkComm.cpp.
|
private |
Definition at line 122 of file ServerNetworkComm.cpp.
|
private |
Definition at line 160 of file ServerNetworkComm.cpp.
|
private |
Definition at line 137 of file ServerNetworkComm.cpp.
bool open_port | ( | unsigned short | port = 62784 | ) |
Opens a port the server has to listen to.
All network interfaces (local loop, ethernet, wi-fi,...) are listened to.
hostAddress | Server address. |
NetworkException | Throws a NetworkException if the server cannot listen to the given port. |
Definition at line 103 of file ServerNetworkComm.cpp.
void run | ( | ) |
Definition at line 77 of file ServerNetworkComm.cpp.
|
private |
Sends a message to a client.
client | Client m_socket to use. If nullptr , the frame will be sent to all clients. |
signal | Signal frame to send. |
|
private |
Definition at line 309 of file ServerNetworkComm.cpp.
void send_frame_rejected_to_client | ( | const std::string | clientid, |
const std::string & | frameid, | ||
const common::URI & | sender, | ||
const std::string & | reason | ||
) |
Definition at line 290 of file ServerNetworkComm.cpp.
void send_frame_to_client | ( | common::XML::SignalFrame & | signal, |
const std::string & | uuid = std::string() |
||
) |
Definition at line 282 of file ServerNetworkComm.cpp.
|
private |
Sends a message to a client.
client | Client socket to use. If nullptr , the message will be sent to all clients. |
message | Message to send. |
true
if the frame was built and sent successfully; otherwise returns false
. Definition at line 325 of file ServerNetworkComm.cpp.
void send_message_to_client | ( | const std::string & | message, |
uiCommon::LogMessage::Type | type, | ||
const std::string & | uuid = std::string() |
||
) |
Sends a message to a client.
message | Message to send |
uuid | Client UuiD, or an empty string to send to all clients. |
UnknownClientIdException | if Client UuiD is unknown. |
Definition at line 300 of file ServerNetworkComm.cpp.
|
private |
Definition at line 128 of file ServerNetworkComm.hpp.
|
private |
Mutex for thread-safe operations.
The client sockets. The key is pointer to the m_socket. The value is the client UuiD.
Definition at line 138 of file ServerNetworkComm.hpp.
|
private |
Definition at line 126 of file ServerNetworkComm.hpp.
|
private |
Definition at line 130 of file ServerNetworkComm.hpp.
Send comments to: COOLFluiD Web Admin |