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

Method receiveAny

source/game/StarUniverseConnection.cpp:91–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91bool UniverseConnection::receiveAny(unsigned timeout) {
92 MutexLocker locker(m_mutex);
93 if (!m_receiveQueue.empty())
94 return true;
95
96 auto timer = Timer::withMilliseconds(timeout);
97 while (true) {
98 m_packetSocket->readData();
99 m_receiveQueue.appendAll(m_packetSocket->receivePackets());
100 if (!m_receiveQueue.empty())
101 return true;
102
103 if (timer.timeUp() || !m_packetSocket->isOpen())
104 return false;
105
106 Thread::sleep(PacketSocketPollSleep);
107 }
108}
109
110PacketSocket& UniverseConnection::packetSocket() {
111 return *m_packetSocket;

Callers 4

connectMethod · 0.80
disconnectMethod · 0.80
acceptConnectionMethod · 0.80
runMethod · 0.80

Calls 6

appendAllMethod · 0.80
receivePacketsMethod · 0.80
timeUpMethod · 0.80
emptyMethod · 0.45
readDataMethod · 0.45
isOpenMethod · 0.45

Tested by 1

runMethod · 0.64