| 360 | } |
| 361 | |
| 362 | bool UniverseServer::executeForClient(ConnectionId clientId, function<void(WorldServer*, PlayerPtr)> action) { |
| 363 | RecursiveMutexLocker locker(m_mainLock); |
| 364 | ReadLocker clientsLocker(m_clientsLock); |
| 365 | bool success = false; |
| 366 | if (auto clientContext = m_clients.value(clientId)) { |
| 367 | if (auto currentWorld = clientContext->playerWorld()) { |
| 368 | locker.unlock(); |
| 369 | currentWorld->executeAction([clientId, action, &success, &locker](WorldServerThread*, WorldServer* worldServer) { |
| 370 | locker.lock(); |
| 371 | if (auto player = worldServer->clientPlayer(clientId)) { |
| 372 | action(worldServer, player); |
| 373 | success = true; |
| 374 | } |
| 375 | }); |
| 376 | } |
| 377 | } |
| 378 | return success; |
| 379 | } |
| 380 | |
| 381 | void UniverseServer::disconnectClient(ConnectionId clientId, String const& reason) { |
| 382 | RecursiveMutexLocker locker(m_mainLock); |
no test coverage detected