//server
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
#include <string>
#include <iostream>
#include <conio.h>
using namespace std;
sf::IpAddress ip= sf::IpAddress::getLocalAddress(); // ustawia lokalny adres komputera na zmienna "IP"
sf::SocketSelector selector;
bool newconn = true;
int port = 2000;
int koniec;
int wait;
std::string t = "3500";
std::vector<sf::TcpSocket*> clients;
sf::TcpSocket* client;
void connections()//zadanie aktualnie - segregowanie użytkowników
{
sf::TcpListener listener; //nasłuchiwanie portu tcp
listener.listen(port);
selector.add(listener);
while(newconn)
{
if (selector.wait()) //czeka na nowego klienta
{
if (selector.isReady(listener))
{
client = new sf::TcpSocket;
if (listener.accept(*client) == sf::Socket::Done)
{
// Add the new client to the clients list
clients.push_back(client);
// Add the new client to the selector so that we will
// be notified when he sends something
selector.add(*client);
cout << "Polaczono z nowym klientem: " << (int)client << endl;
}
}
}
}
}
int main()
{
sf::Thread login(&connections);
login.launch();
sf::Packet test1;
client->receive(test1);
cin >> koniec;
getchar();
return 0;
}