Server.h 722 B

12345678910111213141516171819202122232425262728293031
  1. #ifndef SERVER_H
  2. #define SERVER_H
  3. #include "network/Packet.h"
  4. #include "utils/Error.h"
  5. #include "utils/Types.h"
  6. namespace Server {
  7. typedef uint16 Port;
  8. typedef int Client;
  9. typedef void (*OnConnect)(Client);
  10. typedef void (*OnDisconnect)(Client);
  11. typedef void (*OnPacket)(Client, InPacket&);
  12. Error start(Port port, int maxClients);
  13. void stop();
  14. void tick();
  15. void send(const OutPacket& p, PacketSendMode mode);
  16. void send(Client client, const OutPacket& p, PacketSendMode mode);
  17. void disconnect(Client client);
  18. void setConnectHandler(OnConnect oc);
  19. void setDisconnectHandler(OnDisconnect od);
  20. void setPacketHandler(OnPacket op);
  21. void resetHandler();
  22. }
  23. #endif