This happens when I open server:
But no one is really connecting!
It should write "[MESSAGE] User sent 'connect' message" if "real" client connects.
Also, then my client cant connect beacuse server is busy with receiving all those connections...
Here is code for receiving connections:
while (!done)
{
if (!selector.wait(sf::seconds(8.0f)))
continue;
#pragma region NEW CONNECTION HANDLE
if (selector.isReady(listener)) {
Player m_pl;
sf::TcpSocket *socket = new sf::TcpSocket;
listener.accept(*socket);
#pragma region INIT PACKET
sf::Packet initPacket;
if (socket->receive(initPacket) == sf::Socket::Done) {
std::string msg;
initPacket >> msg;
if (msg == "connect") {
std::cout << "[MESSAGE] User sent \"connect\" message" << std::endl;
}
else {
m_pl.Disconnected = true;
}
}
#pragma endregion
cout << "[ACCEPT] Connection from " << socket->getRemoteAddress() << endl;
// END INITIALIZATION PACKET
m_pl.Disconnected = false;
m_pl.Heartbeat.restart();
m_pl.m_socket = socket;
pl.push_back(m_pl);
selector.add(*socket);
continue;
}
#pragma endregion
//message handling here:
//...
}
Ugh, idk how to explain this...