Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include<SFML/Network.hpp>
  4. #include<iostream>
  5. #include<list>
  6. #include<thread>
  7.  
  8. namespace pt {
  9.     enum {handshake, goodbye, clientInfo};
  10. }
  11.  
  12.  
  13.  
  14. class Server
  15. {
  16. public:
  17.     Server();
  18. private:
  19.     sf::IpAddress ip;
  20.     sf::UdpSocket socket;
  21.     unsigned short port;
  22.  
  23.     struct Client {
  24.         sf::Time timeSinceLastPacket;
  25.         sf::IpAddress ip;
  26.         unsigned short port = 0;
  27.         unsigned short id = 0;
  28.     };
  29.  
  30.     unsigned short id;
  31.  
  32.     std::list<Client> clients;
  33.  
  34.     void run();
  35.  
  36.  
  37.     std::thread listenThread;
  38.  
  39.     const unsigned short ugid = 1907;
  40.  
  41.     void removeClient(unsigned short id);
  42. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement