client.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef __CLIENT__HPP__
  2. #define __CLIENT__HPP__
  3. #include <winsock2.h>
  4. #include <string>
  5. #include <ostream>
  6. #include <Ws2tcpip.h>
  7. #include <iostream>
  8. #include <thread>
  9. #define MSG_BUFFER_SIZE 4096
  10. using namespace std;
  11. class Server;
  12. class Client {
  13. private:
  14. SOCKET socket;
  15. sockaddr_in socketInfo;
  16. string name;
  17. string ip;
  18. u_short port;
  19. thread *workThread;
  20. public:
  21. const SOCKET &getSocket() const;
  22. void setSocket(SOCKET const &socket);
  23. const sockaddr_in &getSocketInfo();
  24. const string &getName() const;
  25. void setName(string const &name);
  26. const string &getIP() const;
  27. void setIP(string const &ip);
  28. const u_short &getPort() const;
  29. void setPort(int const &port);
  30. thread *getWorkThread();
  31. void setWorkThread(thread *workThread);
  32. Client();
  33. Client(const Client&) = delete;
  34. Client(Client&&) = delete;
  35. Client(SOCKET const &socket);
  36. ~Client();
  37. operator string();
  38. const Client &operator=(const Client&) = delete;
  39. const Client &operator=(Client&&) = delete;
  40. void startWorkThread(Server *server);
  41. };
  42. inline ostream &operator<<(ostream &os, Client &client){
  43. return (os << static_cast<string>(client));
  44. }
  45. #endif