hey, when i want erase pointer server stop working...
void Server::Recv()
{
int id = 0;
for ( std::vector<Client*>::iterator it = clients.begin(); it != clients.end(); ++it)
{
id++;
Client &client = **it;
client.ClientID = id;
if ( Selector.isReady( client.Socket ) )
{
if ( client.Socket.receive( client.Recv ) == sf::Socket::Done )
{
std::string str, recv;
std::ostringstream ss;
client.Recv >> str;
ss << client.ClientID;
recv = "Received from ID: " + ss.str();
recv += " " + str;
Console::Out( recv.c_str(), str.c_str() );
client.Recv >> str;
if( str == "Bye" )
{
Selector.remove( client.Socket );
str = "Client: " + ss.str() + " disconnected";
Console::Out( str.c_str() );
clients.erase( it ); // there
}
}
}
}
}
class Client
{
public:
sf::TcpSocket Socket;
sf::Packet Send;
sf::Packet Recv;
int ClientID;
};
any ideas? : /