| 1564 | } |
| 1565 | |
| 1566 | void UniverseServer::packetsReceived(UniverseConnectionServer*, ConnectionId clientId, List<PacketPtr> packets) { |
| 1567 | ReadLocker clientsLocker(m_clientsLock); |
| 1568 | if (auto clientContext = m_clients.value(clientId)) { |
| 1569 | clientsLocker.unlock(); |
| 1570 | |
| 1571 | for (auto& packet : packets) { |
| 1572 | if (auto warpAction = as<PlayerWarpPacket>(packet)) { |
| 1573 | clientWarpPlayer(clientId, warpAction->action, warpAction->deploy); |
| 1574 | |
| 1575 | } else if (auto flyShip = as<FlyShipPacket>(packet)) { |
| 1576 | clientFlyShip(clientId, flyShip->system, flyShip->location, flyShip->settings); |
| 1577 | |
| 1578 | } else if (auto chatSend = as<ChatSendPacket>(packet)) { |
| 1579 | RecursiveMutexLocker locker(m_mainLock); |
| 1580 | m_pendingChat[clientId].append(make_tuple(std::move(chatSend->text), chatSend->sendMode, std::move(chatSend->data))); |
| 1581 | |
| 1582 | } else if (auto clientContextUpdatePacket = as<ClientContextUpdatePacket>(packet)) { |
| 1583 | clientContext->readUpdate(std::move(clientContextUpdatePacket->updateData)); |
| 1584 | |
| 1585 | } else if (auto clientDisconnectPacket = as<ClientDisconnectRequestPacket>(packet)) { |
| 1586 | disconnectClient(clientId, String()); |
| 1587 | |
| 1588 | } else if (auto celestialRequest = as<CelestialRequestPacket>(packet)) { |
| 1589 | addCelestialRequests(clientId, std::move(celestialRequest->requests)); |
| 1590 | |
| 1591 | } else if (is<SystemObjectSpawnPacket>(packet)) { |
| 1592 | if (auto currentSystem = clientContext->systemWorld()) |
| 1593 | currentSystem->pushIncomingPacket(clientId, std::move(packet)); |
| 1594 | } else { |
| 1595 | if (auto currentWorld = clientContext->playerWorld()) |
| 1596 | currentWorld->pushIncomingPackets(clientId, {std::move(packet)}); |
| 1597 | } |
| 1598 | } |
| 1599 | } |
| 1600 | } |
| 1601 | |
| 1602 | void UniverseServer::acceptConnection(UniverseConnection connection, Maybe<HostAddress> remoteAddress) { |
| 1603 | auto& root = Root::singleton(); |
nothing calls this directly
no test coverage detected