18 #include <sys/select.h>
23 class IProtocolMessage;
26 explicit Client(SOCKET _socket) :
27 socket(_socket), finished(
false), in(), out() {
39 virtual void onConnect(
Client*) {}
40 virtual void onDisconnect(
Client*) {}
46 std::string _hostname;
53 typedef std::list<Client> ClientSockets;
54 typedef ClientSockets::iterator ClientSocketsIter;
55 ClientSockets _clientSockets;
56 ClientSocketsIter closeClient (ClientSocketsIter& i);
58 typedef std::list<INetworkListener*> Listeners;
61 bool sendMessage(
Client& client);
63 Network(uint16_t port = 10001,
const std::string& hostname =
"0.0.0.0");
67 void update(int64_t deltaTime);
72 int getConnectedClients()
const;
81 inline int Network::getConnectedClients()
const {
82 return static_cast<int>(_clientSockets.size());
85 inline void Network::addListener(INetworkListener* listener) {
86 _listeners.push_back(listener);
89 inline void Network::removeListener(INetworkListener* listener) {
90 _listeners.remove(listener);
A protocol message is used for the serialization of the ai states for remote debugging.
Definition: IProtocolMessage.h:60
bool broadcast(const IProtocolMessage &msg)
Definition: NetworkImpl.h:230