Explicitly close sockets when plugin is stopped

This commit is contained in:
Ted John committed 2020-09-03 22:38:42 +01:00
1 parent 33ba51b763
commit 858bb4045f
1 file changed
+14 -4
+14 -4
View File
@@ -1165,10 +1165,20 @@ void ScriptEngine::UpdateSockets()
void ScriptEngine::RemoveSockets(const std::shared_ptr<Plugin>& plugin)
{
# ifndef DISABLE_NETWORK
_sockets.erase(
std::remove_if(
_sockets.begin(), _sockets.end(), [&plugin](const auto& socket) { return socket->GetPlugin() == plugin; }),
_sockets.end());
auto it = _sockets.begin();
while (it != _sockets.end())
{
auto socket = it->get();
if (socket->GetPlugin() == plugin)
{
socket->Dispose();
it = _sockets.erase(it);
}
else
{
it++;
}
}
# endif
}