mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 14:49:32 +02:00
add method to packet sender to flush queue without sleep
This commit is contained in:
parent
04c4dabd3d
commit
6533d7fcde
3 changed files with 22 additions and 2 deletions
|
@ -82,8 +82,8 @@ void Agent::run() {
|
||||||
|
|
||||||
// allow the scripter's call back to setup visual data
|
// allow the scripter's call back to setup visual data
|
||||||
emit preSendCallback();
|
emit preSendCallback();
|
||||||
// flush the voxel packet queue
|
// flush the voxel packet queue, don't allow it to sleep us
|
||||||
voxelScripter.getVoxelPacketSender()->process();
|
voxelScripter.getVoxelPacketSender()->processWithoutSleep();
|
||||||
|
|
||||||
while (NodeList::getInstance()->getNodeSocket()->receive((sockaddr*) &senderAddress, receivedData, &receivedBytes)) {
|
while (NodeList::getInstance()->getNodeSocket()->receive((sockaddr*) &senderAddress, receivedData, &receivedBytes)) {
|
||||||
NodeList::getInstance()->processNodeData((sockaddr*) &senderAddress, receivedData, receivedBytes);
|
NodeList::getInstance()->processNodeData((sockaddr*) &senderAddress, receivedData, receivedBytes);
|
||||||
|
|
|
@ -68,3 +68,22 @@ bool PacketSender::process() {
|
||||||
}
|
}
|
||||||
return isStillRunning(); // keep running till they terminate us
|
return isStillRunning(); // keep running till they terminate us
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PacketSender::processWithoutSleep() {
|
||||||
|
while (_packets.size() > 0) {
|
||||||
|
NetworkPacket& packet = _packets.front();
|
||||||
|
|
||||||
|
// send the packet through the NodeList...
|
||||||
|
UDPSocket* nodeSocket = NodeList::getInstance()->getNodeSocket();
|
||||||
|
|
||||||
|
nodeSocket->send(&packet.getAddress(), packet.getData(), packet.getLength());
|
||||||
|
|
||||||
|
if (_notify) {
|
||||||
|
_notify->packetSentNotification(packet.getLength());
|
||||||
|
}
|
||||||
|
|
||||||
|
lock();
|
||||||
|
_packets.erase(_packets.begin());
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
PacketSenderNotify* getPacketSenderNotify() const { return _notify; }
|
PacketSenderNotify* getPacketSenderNotify() const { return _notify; }
|
||||||
|
|
||||||
virtual bool process();
|
virtual bool process();
|
||||||
|
virtual void processWithoutSleep();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int _packetsPerSecond;
|
int _packetsPerSecond;
|
||||||
|
|
Loading…
Reference in a new issue