#include <server.h>
Public Types | |
enum | server_command { CMD_REGISTER, CMD_REGISTER_ACK, CMD_PING, CMD_LEAVE, CMD_GET_CLIENT_INFO, CMD_GET_CLIENT_INFO_REPLY, CMD_CONNECT, CMD_CONNECT_ACK, CMD_CONNECT_OK, CMD_CONNECT_OK_ACK, CMD_SMSG, CMD_SMSG_ACK, CMD_DISCONNECT } |
enum | server_messages { MSG_OK = 0, MSG_ALREADY_REGISTERED, MSG_NOT_FOUND } |
Public Member Functions | |
int | listen (int port) |
int | shutdown (std::string message) |
int | check_clients_status () |
int | show_clients () |
int | sendCommand (enum server_command cmd, net::Socket &sock) |
Classes | |
struct | packet |
Definition at line 20 of file server.h.
int n2nc::Server::listen | ( | int | port | ) |
brings the server to listen at given port
Definition at line 61 of file server.cpp.
References n2nc::net::SocketEventsHandler::add(), n2nc::net::Socket::bind(), n2nc::net::Resolver::getSocketAddressByService(), n2nc::net::SocketEventsHandler::READ, n2nc::net::TcpSocket::setListen(), and n2nc::net::SocketEventsHandler::waitForEvents().
int n2nc::Server::shutdown | ( | std::string | message | ) |
causes the server shutdown just after sending the given message to clients
Definition at line 75 of file server.cpp.
int n2nc::Server::check_clients_status | ( | ) |
checks if any client goes to timeout, if so that client will be removed from the list of online peers
Definition at line 265 of file server.cpp.
References n2nc::sync::Mutex::lock(), and n2nc::sync::Mutex::unlock().