Symphony Of Empires
Server Class Reference

#include <server_network.hpp>

Inheritance diagram for Server:
Collaboration diagram for Server:

Classes

struct  ClientData
 

Public Member Functions

 Server (GameState &gs, unsigned port=1825, unsigned max_conn=4)
 
 ~Server ()=default
 
void netloop (int id)
 This is the handling thread-function for handling a connection to a single client Sending packets will only be received by the other end, when trying to broadcast please put the packets on the send queue, they will be sent accordingly. More...
 
void on_connect (int conn_fd, int id) override
 
void on_disconnect () override
 
void handler (const Eng3D::Networking::Packet &packet, Eng3D::Deser::Archive &ar, int id) override
 
- Public Member Functions inherited from Eng3D::Networking::Server
 Server (unsigned port, unsigned max_conn)
 
 ~Server ()
 
void broadcast (const Eng3D::Networking::Packet &packet)
 This will broadcast the given packet to all clients currently on the server. More...
 
void do_netloop (std::function< void(int i)> on_wake_thread, int id)
 

Public Attributes

std::vector< ClientDataclients_data
 
std::vector< Nation * > clients_extra_data
 
std::unordered_map< ActionType, std::function< void(ClientData &client_data, const Eng3D::Networking::Packet &packet, Eng3D::Deser::Archive &ar)> > action_handlers
 
- Public Attributes inherited from Eng3D::Networking::Server
ServerClientclients
 
std::size_t n_clients
 
std::size_t player_count = 0
 

Additional Inherited Members

- Protected Attributes inherited from Eng3D::Networking::Server
struct sockaddr_in addr
 
int fd
 
std::atomic< bool > run
 

Detailed Description

Definition at line 49 of file server_network.hpp.

Constructor & Destructor Documentation

◆ Server()

Server::Server ( GameState gs,
unsigned  port = 1825,
unsigned  max_conn = 4 
)
Todo:
Find building
Todo:
Check nation can build this unit

Definition at line 40 of file server_network.cpp.

Here is the call graph for this function:

◆ ~Server()

Server::~Server ( )
default

Member Function Documentation

◆ handler()

void Server::handler ( const Eng3D::Networking::Packet packet,
Eng3D::Deser::Archive ar,
int  id 
)
overridevirtual

Implements Eng3D::Networking::Server.

Definition at line 272 of file server_network.cpp.

◆ netloop()

void Server::netloop ( int  id)

This is the handling thread-function for handling a connection to a single client Sending packets will only be received by the other end, when trying to broadcast please put the packets on the send queue, they will be sent accordingly.

Definition at line 293 of file server_network.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_connect()

void Server::on_connect ( int  conn_fd,
int  id 
)
overridevirtual

Implements Eng3D::Networking::Server.

Definition at line 230 of file server_network.cpp.

◆ on_disconnect()

void Server::on_disconnect ( )
overridevirtual

Implements Eng3D::Networking::Server.

Definition at line 264 of file server_network.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ action_handlers

std::unordered_map<ActionType, std::function<void(ClientData& client_data, const Eng3D::Networking::Packet& packet, Eng3D::Deser::Archive& ar)> > Server::action_handlers

Definition at line 72 of file server_network.hpp.

◆ clients_data

std::vector<ClientData> Server::clients_data

Definition at line 70 of file server_network.hpp.

◆ clients_extra_data

std::vector<Nation*> Server::clients_extra_data

Definition at line 71 of file server_network.hpp.


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