|
RType
|
#include <ServerSocket.hpp>


Public Member Functions | |
| ServerSocket () | |
| Constructor of ServerSocket. More... | |
| ~ServerSocket () override | |
| Destructor of ServerSocket. More... | |
| void | init_server (int port) |
| Init the server socket. More... | |
| void | send (Packet *packet, struct sockaddr_in dest) override |
| Send a packet to a client. More... | |
| void | sendPacket (SplitPacket *packet, struct sockaddr_in dest) override |
| Send a split packet to a client. More... | |
| void | broadcast (Packet *packet) |
| Broadcast a packet to all clients. More... | |
| std::tuple< std::unique_ptr< Packet >, int > | receive () override |
| Receive a packet from a client. More... | |
| void | run () override |
| Run the server socket. More... | |
| void | addClient (struct sockaddr_in client) |
| Add a client to the server. More... | |
| int | getClientId (sockaddr_in client) |
| Remove a client from the server. More... | |
| struct sockaddr_in | getClientAddress (int id) |
| Get the client address. More... | |
| void | init_fd_set () |
| init_fd_set, init the fd_set More... | |
| void | splitAndSend (Packet *packet, struct sockaddr_in dest) override |
| split and send a packet to a client More... | |
| void | receivePacketAndAddToBuffer () |
| receivePacketAndAddToBuffer, receive a packet and add it to the buffer More... | |
| std::vector< std::tuple< int, struct sockaddr_in, std::vector< std::tuple< std::shared_ptr< SplitPacket >, timeval > >, timeval > > & | getClients () |
| getClients, get the clients More... | |
| std::tuple< std::unique_ptr< Packet >, int > | manageClientsBuffer () |
| manageClientsBuffer, manage the clients buffer More... | |
| void | setNewClientConnected (int newClientConnected) |
| setNewClientConnected, set the new client connected More... | |
| int | getNewClientId () |
| getNewClientId, get the new client id More... | |
| int | checkClientsDeconnection () |
| checkClientsDeconnection, check if a client is disconnected More... | |
| void | clientDump () |
| clientDump, dump the clients More... | |
Public Member Functions inherited from USocket | |
| virtual | ~USocket ()=default |
| Destructor of USocket. More... | |
Definition at line 19 of file ServerSocket.hpp.
| ServerSocket::ServerSocket | ( | ) |
Constructor of ServerSocket.
Definition at line 17 of file ServerSocket.cpp.
|
override |
Destructor of ServerSocket.
Definition at line 50 of file ServerSocket.cpp.
| void ServerSocket::addClient | ( | struct sockaddr_in | client | ) |
Add a client to the server.
| client |
Definition at line 105 of file ServerSocket.cpp.
Referenced by receivePacketAndAddToBuffer().

| void ServerSocket::broadcast | ( | Packet * | packet | ) |
Broadcast a packet to all clients.
| packet |
Definition at line 289 of file ServerSocket.cpp.
| int ServerSocket::checkClientsDeconnection | ( | ) |
checkClientsDeconnection, check if a client is disconnected
Definition at line 451 of file ServerSocket.cpp.
| void ServerSocket::clientDump | ( | ) |
clientDump, dump the clients
Definition at line 509 of file ServerSocket.cpp.
| struct sockaddr_in ServerSocket::getClientAddress | ( | int | id | ) |
Get the client address.
| id |
Definition at line 265 of file ServerSocket.cpp.
| int ServerSocket::getClientId | ( | sockaddr_in | client | ) |
Remove a client from the server.
| client |
Definition at line 123 of file ServerSocket.cpp.
Referenced by receivePacketAndAddToBuffer().

| std::vector< std::tuple< int, struct sockaddr_in, std::vector< std::tuple< std::shared_ptr< SplitPacket >, timeval > >, timeval > > & ServerSocket::getClients | ( | ) |
getClients, get the clients
Definition at line 265 of file ServerSocket.cpp.
| int ServerSocket::getNewClientId | ( | ) |
getNewClientId, get the new client id
Definition at line 497 of file ServerSocket.cpp.
| void ServerSocket::init_fd_set | ( | ) |
init_fd_set, init the fd_set
Definition at line 232 of file ServerSocket.cpp.
Referenced by run().

| void ServerSocket::init_server | ( | int | port | ) |
Init the server socket.
| port |
Definition at line 63 of file ServerSocket.cpp.
Referenced by main().

| std::tuple< std::unique_ptr< Packet >, int > ServerSocket::manageClientsBuffer | ( | ) |
manageClientsBuffer, manage the clients buffer
Definition at line 379 of file ServerSocket.cpp.
|
overridevirtual |
Receive a packet from a client.
Implements USocket.
Definition at line 140 of file ServerSocket.cpp.
References receivePacketAndAddToBuffer().

| void ServerSocket::receivePacketAndAddToBuffer | ( | ) |
receivePacketAndAddToBuffer, receive a packet and add it to the buffer
Definition at line 335 of file ServerSocket.cpp.
References addClient(), getClientId(), and setNewClientConnected().
Referenced by receive().


|
overridevirtual |
Run the server socket.
Implements USocket.
Definition at line 241 of file ServerSocket.cpp.
References init_fd_set().
Referenced by main().


|
overridevirtual |
Send a packet to a client.
| packet | |
| dest |
Implements USocket.
Definition at line 79 of file ServerSocket.cpp.
References splitAndSend().

|
overridevirtual |
Send a split packet to a client.
| packet | |
| dest |
Implements USocket.
Definition at line 89 of file ServerSocket.cpp.
| void ServerSocket::setNewClientConnected | ( | int | newClientConnected | ) |
setNewClientConnected, set the new client connected
| newClientConnected |
Definition at line 487 of file ServerSocket.cpp.
Referenced by receivePacketAndAddToBuffer().

|
overridevirtual |
split and send a packet to a client
| packet | |
| dest |
Implements USocket.
Definition at line 301 of file ServerSocket.cpp.
References packet::data_size.
Referenced by send().
