Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <fstream>
- #include <string>
- #include <thread>
- #include <SFML/System.hpp>
- #include <SFML/Network.hpp>
- using namespace std;
- class User{
- public:
- User(string User);
- string Name;
- int ID;
- static int Users;
- }
- User::User(string User){
- ID=++Users;
- Name=User;
- }
- class Chat{
- public:
- Chat();
- private:
- sf::SendMessage();
- sf::TcpSocket Client[100];
- sf::TcpListener Server;
- int Clients;
- bool NewUser;
- void newClient();
- };
- Chat::Chat(){
- Server.listen(23);
- NewUser=true;
- while(true){
- if(NewUser){
- cout<<"Ready for new connection";
- std::thread NewUser(newClient);
- NewUser.join();
- }}
- }+;
- void Chat::newClient(){
- NewUser=false;
- if(Server.accept(Client[Clients])){
- cout<<"New Client";
- Clients++;
- NewUser=true;
- }
- User NewUser;
- char Message[200];
- while(Server.receive(Message,200)){
- }
- }
- int main(){
- Chat chat;
- sf::sleep(sf::seconds(19));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement