MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / packetsReceived

Method packetsReceived

source/game/StarUniverseServer.cpp:1566–1600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1564}
1565
1566void 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
1602void UniverseServer::acceptConnection(UniverseConnection connection, Maybe<HostAddress> remoteAddress) {
1603 auto& root = Root::singleton();

Callers

nothing calls this directly

Calls 9

StringClass · 0.85
systemWorldMethod · 0.80
pushIncomingPacketMethod · 0.80
pushIncomingPacketsMethod · 0.80
valueMethod · 0.45
unlockMethod · 0.45
appendMethod · 0.45
readUpdateMethod · 0.45
playerWorldMethod · 0.45

Tested by

no test coverage detected