#ifndef SERVER_H #define SERVER_H #include #include #include "packet.h" #include "simulation.h" class QTimer; class QTcpServer; class QTcpSocket; class ServerClient; class Server : public QObject { Q_OBJECT public: explicit Server(unsigned short port = 20202, QObject *parent = 0); ~Server(); QTcpServer* server; QTimer* timer; Simulation simulation; std::vector* worldData; std::vector clients; int currentClient; signals: void outMessage(QString); void errMessage(QString); public slots: void update(); void on_newConnection(); void onClientDelta(int, DeltaClientPacket*); }; class ServerClient : public QObject { Q_OBJECT public: ServerClient(int id, QTcpSocket* mySocket); ~ServerClient(); bool isOk() {return ok;} void sendDelta(); void sendFull(const std::vector &clients, int id); private: bool ok; int myId; QTcpSocket* socket; public slots: void on_disconnected(); void on_readyRead(); signals: void receivedDelta(int, DeltaClientPacket*); void outMessage(QString); void errMessage(QString); }; #endif // SERVER_H