mirror of
https://github.com/lubosz/overte.git
synced 2025-04-08 21:42:24 +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
|
||||
emit preSendCallback();
|
||||
// flush the voxel packet queue
|
||||
voxelScripter.getVoxelPacketSender()->process();
|
||||
// flush the voxel packet queue, don't allow it to sleep us
|
||||
voxelScripter.getVoxelPacketSender()->processWithoutSleep();
|
||||
|
||||
while (NodeList::getInstance()->getNodeSocket()->receive((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
|
||||
}
|
||||
|
||||
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; }
|
||||
|
||||
virtual bool process();
|
||||
virtual void processWithoutSleep();
|
||||
|
||||
protected:
|
||||
int _packetsPerSecond;
|
||||
|
|
Loading…
Reference in a new issue