Advertisement
Venomshq

Chat Server

Dec 16th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <fstream>
  4. #include <string>
  5. #include <thread>
  6. #include <SFML/System.hpp>
  7. #include <SFML/Network.hpp>
  8. using namespace std;
  9. class User{
  10. public:
  11. User(string User);
  12. string Name;
  13. int ID;
  14. static int Users;
  15. }
  16. User::User(string User){
  17. ID=++Users;
  18. Name=User;
  19. }
  20. class Chat{
  21. public:
  22. Chat();
  23. private:
  24. sf::SendMessage();
  25. sf::TcpSocket Client[100];
  26. sf::TcpListener Server;
  27. int Clients;
  28. bool NewUser;
  29. void newClient();
  30. };
  31. Chat::Chat(){
  32. Server.listen(23);
  33. NewUser=true;
  34. while(true){
  35. if(NewUser){
  36. cout<<"Ready for new connection";
  37. std::thread NewUser(newClient);
  38. NewUser.join();
  39. }}
  40. }+;
  41. void Chat::newClient(){
  42. NewUser=false;
  43. if(Server.accept(Client[Clients])){
  44. cout<<"New Client";
  45. Clients++;
  46. NewUser=true;
  47. }
  48. User NewUser;
  49. char Message[200];
  50. while(Server.receive(Message,200)){
  51.  
  52. }
  53. }
  54. int main(){
  55. Chat chat;
  56. sf::sleep(sf::seconds(19));
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement