Cleaned up socket scheduling. Very clean now.

This commit is contained in:
Brad Arant committed 2022-03-15 21:02:35 +00:00
1 parent 4017ee9175
commit 3a6883e77f
8 files changed
+34 -45

No files matched your search

+14 -12
View File
@@ -72,8 +72,10 @@ namespace core {
std::vector<TCPSession *>::iterator cursor;
lock.lock();
for(cursor = sessions.begin(); cursor < sessions.end(); ++cursor)
if(*cursor == session)
sessions.erase(cursor);
if(*cursor == session) {
sessions.erase(cursor);
break;
}
lock.unlock();
}
@@ -98,26 +100,26 @@ namespace core {
}
return 1;
}
void TCPServer::sendToAll(std::stringstream &data) {
for(auto session : sessions)
session->write(data.str());
session->write(data.str());
data.str("");
}
void TCPServer::sendToAll(std::stringstream &data, TCPSession &sender) {
for(auto session : sessions)
if(session != &sender)
session->write(data.str());
if(session != &sender)
session->write(data.str());
data.str("");
}
void TCPServer::sendToAll(std::stringstream &data, TCPSession &sender, SessionFilter filter) {
for(auto session : sessions)
if(filter.test(*session))
if(session != &sender)
session->write(data.str());
if(filter.test(*session))
if(session != &sender)
session->write(data.str());
data.str("");
}
}