mirror of
https://github.com/overte-org/overte.git
synced 2025-04-29 19:02:36 +02:00
handle merge with nodelist-patches branch
This commit is contained in:
commit
4ebd5795fc
15 changed files with 50 additions and 66 deletions
|
@ -144,8 +144,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
_enableProcessVoxelsThread(true),
|
_enableProcessVoxelsThread(true),
|
||||||
_voxelProcessor(),
|
_voxelProcessor(),
|
||||||
_voxelHideShowThread(&_voxels),
|
_voxelHideShowThread(&_voxels),
|
||||||
_voxelEditSender(this),
|
|
||||||
_particleEditSender(this),
|
|
||||||
_packetsPerSecond(0),
|
_packetsPerSecond(0),
|
||||||
_bytesPerSecond(0),
|
_bytesPerSecond(0),
|
||||||
_recentMaxPackets(0),
|
_recentMaxPackets(0),
|
||||||
|
@ -231,6 +229,10 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
<< NODE_TYPE_VOXEL_SERVER << NODE_TYPE_PARTICLE_SERVER
|
<< NODE_TYPE_VOXEL_SERVER << NODE_TYPE_PARTICLE_SERVER
|
||||||
<< NODE_TYPE_METAVOXEL_SERVER);
|
<< NODE_TYPE_METAVOXEL_SERVER);
|
||||||
|
|
||||||
|
// connect to the packet sent signal of the _voxelEditSender and the _particleEditSender
|
||||||
|
connect(&_voxelEditSender, &VoxelEditPacketSender::packetSent, this, &Application::packetSent);
|
||||||
|
connect(&_particleEditSender, &ParticleEditPacketSender::packetSent, this, &Application::packetSent);
|
||||||
|
|
||||||
// move the silentNodeTimer to the _nodeThread
|
// move the silentNodeTimer to the _nodeThread
|
||||||
QTimer* silentNodeTimer = new QTimer();
|
QTimer* silentNodeTimer = new QTimer();
|
||||||
connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));
|
connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));
|
||||||
|
@ -639,21 +641,20 @@ void Application::resetProfile(const QString& username) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||||
const char* nodeTypes, int numNodeTypes) {
|
const QSet<NODE_TYPE>& destinationNodeTypes) {
|
||||||
Application* self = getInstance();
|
foreach(NODE_TYPE type, destinationNodeTypes) {
|
||||||
for (int i = 0; i < numNodeTypes; ++i) {
|
|
||||||
|
|
||||||
// Intercept data to voxel server when voxels are disabled
|
// Intercept data to voxel server when voxels are disabled
|
||||||
if (nodeTypes[i] == NODE_TYPE_VOXEL_SERVER && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
|
if (type == NODE_TYPE_VOXEL_SERVER && !Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform the broadcast for one type
|
// Perform the broadcast for one type
|
||||||
int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(broadcastData, dataBytes, & nodeTypes[i], 1);
|
int nReceivingNodes = NodeList::getInstance()->broadcastToNodes(broadcastData, dataBytes,
|
||||||
|
QSet<NODE_TYPE>() << type);
|
||||||
|
|
||||||
// Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise)
|
// Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise)
|
||||||
BandwidthMeter::ChannelIndex channel;
|
BandwidthMeter::ChannelIndex channel;
|
||||||
switch (nodeTypes[i]) {
|
switch (type) {
|
||||||
case NODE_TYPE_AGENT:
|
case NODE_TYPE_AGENT:
|
||||||
case NODE_TYPE_AVATAR_MIXER:
|
case NODE_TYPE_AVATAR_MIXER:
|
||||||
channel = BandwidthMeter::AVATARS;
|
channel = BandwidthMeter::AVATARS;
|
||||||
|
@ -664,7 +665,7 @@ void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
self->_bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * dataBytes);
|
_bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * dataBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1319,15 +1320,13 @@ void Application::wheelEvent(QWheelEvent* event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::sendPingPackets() {
|
void Application::sendPingPackets() {
|
||||||
|
|
||||||
const char nodesToPing[] = {NODE_TYPE_VOXEL_SERVER, NODE_TYPE_PARTICLE_SERVER,
|
|
||||||
NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_METAVOXEL_SERVER};
|
|
||||||
|
|
||||||
unsigned char pingPacket[MAX_PACKET_SIZE];
|
unsigned char pingPacket[MAX_PACKET_SIZE];
|
||||||
int length = NodeList::getInstance()->fillPingPacket(pingPacket);
|
int length = NodeList::getInstance()->fillPingPacket(pingPacket);
|
||||||
|
|
||||||
getInstance()->controlledBroadcastToNodes(pingPacket, length,
|
getInstance()->controlledBroadcastToNodes(pingPacket, length, QSet<NODE_TYPE>()
|
||||||
nodesToPing, sizeof(nodesToPing));
|
<< NODE_TYPE_VOXEL_SERVER << NODE_TYPE_PARTICLE_SERVER
|
||||||
|
<< NODE_TYPE_AUDIO_MIXER << NODE_TYPE_AVATAR_MIXER
|
||||||
|
<< NODE_TYPE_METAVOXEL_SERVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Every second, check the frame rates and other stuff
|
// Every second, check the frame rates and other stuff
|
||||||
|
@ -2369,9 +2368,8 @@ void Application::updateAvatar(float deltaTime) {
|
||||||
|
|
||||||
endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite);
|
endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite);
|
||||||
|
|
||||||
const char nodeTypesOfInterest[] = { NODE_TYPE_AVATAR_MIXER };
|
|
||||||
controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString,
|
controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString,
|
||||||
nodeTypesOfInterest, sizeof(nodeTypesOfInterest));
|
QSet<NODE_TYPE>() << NODE_TYPE_AVATAR_MIXER);
|
||||||
|
|
||||||
// Update _viewFrustum with latest camera and view frustum data...
|
// Update _viewFrustum with latest camera and view frustum data...
|
||||||
// NOTE: we get this from the view frustum, to make it simpler, since the
|
// NOTE: we get this from the view frustum, to make it simpler, since the
|
||||||
|
@ -3911,7 +3909,7 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen
|
||||||
return statsMessageLength;
|
return statsMessageLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::packetSentNotification(ssize_t length) {
|
void Application::packetSent(quint64 length) {
|
||||||
_bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length);
|
_bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ static const float NODE_KILLED_RED = 1.0f;
|
||||||
static const float NODE_KILLED_GREEN = 0.0f;
|
static const float NODE_KILLED_GREEN = 0.0f;
|
||||||
static const float NODE_KILLED_BLUE = 0.0f;
|
static const float NODE_KILLED_BLUE = 0.0f;
|
||||||
|
|
||||||
class Application : public QApplication, public PacketSenderNotify {
|
class Application : public QApplication {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
friend class VoxelPacketProcessor;
|
friend class VoxelPacketProcessor;
|
||||||
|
@ -172,8 +172,8 @@ public:
|
||||||
Profile* getProfile() { return &_profile; }
|
Profile* getProfile() { return &_profile; }
|
||||||
void resetProfile(const QString& username);
|
void resetProfile(const QString& username);
|
||||||
|
|
||||||
static void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||||
const char* nodeTypes, int numNodeTypes);
|
const QSet<NODE_TYPE>& destinationNodeTypes);
|
||||||
|
|
||||||
void setupWorldLight();
|
void setupWorldLight();
|
||||||
|
|
||||||
|
@ -189,9 +189,6 @@ public:
|
||||||
void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
||||||
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const;
|
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const;
|
||||||
|
|
||||||
|
|
||||||
virtual void packetSentNotification(ssize_t length);
|
|
||||||
|
|
||||||
VoxelShader& getVoxelShader() { return _voxelShader; }
|
VoxelShader& getVoxelShader() { return _voxelShader; }
|
||||||
PointShader& getPointShader() { return _pointShader; }
|
PointShader& getPointShader() { return _pointShader; }
|
||||||
FileLogger* getLogger() { return _logger; }
|
FileLogger* getLogger() { return _logger; }
|
||||||
|
@ -210,6 +207,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void domainChanged(const QString& domainHostname);
|
void domainChanged(const QString& domainHostname);
|
||||||
void nodeKilled(SharedNodePointer node);
|
void nodeKilled(SharedNodePointer node);
|
||||||
|
void packetSent(quint64 length);
|
||||||
|
|
||||||
void exportVoxels();
|
void exportVoxels();
|
||||||
void importVoxels();
|
void importVoxels();
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
#include <PacketHeaders.h>
|
#include <PacketHeaders.h>
|
||||||
#include "JurisdictionListener.h"
|
#include "JurisdictionListener.h"
|
||||||
|
|
||||||
JurisdictionListener::JurisdictionListener(NODE_TYPE type, PacketSenderNotify* notify) :
|
JurisdictionListener::JurisdictionListener(NODE_TYPE type) :
|
||||||
_packetSender(notify, JurisdictionListener::DEFAULT_PACKETS_PER_SECOND)
|
_packetSender(JurisdictionListener::DEFAULT_PACKETS_PER_SECOND)
|
||||||
{
|
{
|
||||||
_nodeType = type;
|
_nodeType = type;
|
||||||
ReceivedPacketProcessor::_dontSleep = true; // we handle sleeping so this class doesn't need to
|
ReceivedPacketProcessor::_dontSleep = true; // we handle sleeping so this class doesn't need to
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
static const int DEFAULT_PACKETS_PER_SECOND = 1;
|
static const int DEFAULT_PACKETS_PER_SECOND = 1;
|
||||||
static const int NO_SERVER_CHECK_RATE = 60; // if no servers yet detected, keep checking at 60fps
|
static const int NO_SERVER_CHECK_RATE = 60; // if no servers yet detected, keep checking at 60fps
|
||||||
|
|
||||||
JurisdictionListener(NODE_TYPE type = NODE_TYPE_VOXEL_SERVER, PacketSenderNotify* notify = NULL);
|
JurisdictionListener(NODE_TYPE type = NODE_TYPE_VOXEL_SERVER);
|
||||||
|
|
||||||
virtual bool process();
|
virtual bool process();
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
#include "JurisdictionSender.h"
|
#include "JurisdictionSender.h"
|
||||||
|
|
||||||
|
|
||||||
JurisdictionSender::JurisdictionSender(JurisdictionMap* map, NODE_TYPE type, PacketSenderNotify* notify) :
|
JurisdictionSender::JurisdictionSender(JurisdictionMap* map, NODE_TYPE type) :
|
||||||
ReceivedPacketProcessor(),
|
ReceivedPacketProcessor(),
|
||||||
_jurisdictionMap(map),
|
_jurisdictionMap(map),
|
||||||
_packetSender(notify, JurisdictionSender::DEFAULT_PACKETS_PER_SECOND)
|
_packetSender(JurisdictionSender::DEFAULT_PACKETS_PER_SECOND)
|
||||||
{
|
{
|
||||||
_nodeType = type;
|
_nodeType = type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ class JurisdictionSender : public ReceivedPacketProcessor {
|
||||||
public:
|
public:
|
||||||
static const int DEFAULT_PACKETS_PER_SECOND = 1;
|
static const int DEFAULT_PACKETS_PER_SECOND = 1;
|
||||||
|
|
||||||
JurisdictionSender(JurisdictionMap* map, NODE_TYPE type = NODE_TYPE_VOXEL_SERVER, PacketSenderNotify* notify = NULL);
|
JurisdictionSender(JurisdictionMap* map, NODE_TYPE type = NODE_TYPE_VOXEL_SERVER);
|
||||||
~JurisdictionSender();
|
~JurisdictionSender();
|
||||||
|
|
||||||
void setJurisdiction(JurisdictionMap* map) { _jurisdictionMap = map; }
|
void setJurisdiction(JurisdictionMap* map) { _jurisdictionMap = map; }
|
||||||
|
|
|
@ -27,8 +27,8 @@ EditPacketBuffer::EditPacketBuffer(PACKET_TYPE type, unsigned char* buffer, ssiz
|
||||||
const int OctreeEditPacketSender::DEFAULT_MAX_PENDING_MESSAGES = PacketSender::DEFAULT_PACKETS_PER_SECOND;
|
const int OctreeEditPacketSender::DEFAULT_MAX_PENDING_MESSAGES = PacketSender::DEFAULT_PACKETS_PER_SECOND;
|
||||||
|
|
||||||
|
|
||||||
OctreeEditPacketSender::OctreeEditPacketSender(PacketSenderNotify* notify) :
|
OctreeEditPacketSender::OctreeEditPacketSender() :
|
||||||
PacketSender(notify),
|
PacketSender(),
|
||||||
_shouldSend(true),
|
_shouldSend(true),
|
||||||
_maxPendingMessages(DEFAULT_MAX_PENDING_MESSAGES),
|
_maxPendingMessages(DEFAULT_MAX_PENDING_MESSAGES),
|
||||||
_releaseQueuedMessagesPending(false),
|
_releaseQueuedMessagesPending(false),
|
||||||
|
|
|
@ -28,8 +28,9 @@ public:
|
||||||
|
|
||||||
/// Utility for processing, packing, queueing and sending of outbound edit messages.
|
/// Utility for processing, packing, queueing and sending of outbound edit messages.
|
||||||
class OctreeEditPacketSender : public PacketSender {
|
class OctreeEditPacketSender : public PacketSender {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
OctreeEditPacketSender(PacketSenderNotify* notify = NULL);
|
OctreeEditPacketSender();
|
||||||
~OctreeEditPacketSender();
|
~OctreeEditPacketSender();
|
||||||
|
|
||||||
/// Queues a single edit message. Will potentially send a pending multi-command packet. Determines which server
|
/// Queues a single edit message. Will potentially send a pending multi-command packet. Determines which server
|
||||||
|
|
|
@ -16,10 +16,8 @@
|
||||||
|
|
||||||
/// Utility for processing, packing, queueing and sending of outbound edit voxel messages.
|
/// Utility for processing, packing, queueing and sending of outbound edit voxel messages.
|
||||||
class ParticleEditPacketSender : public OctreeEditPacketSender {
|
class ParticleEditPacketSender : public OctreeEditPacketSender {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ParticleEditPacketSender(PacketSenderNotify* notify = NULL) : OctreeEditPacketSender(notify) { }
|
|
||||||
~ParticleEditPacketSender() { }
|
|
||||||
|
|
||||||
/// Send particle add message immediately
|
/// Send particle add message immediately
|
||||||
/// NOTE: ParticleProperties assumes that all distances are in meter units
|
/// NOTE: ParticleProperties assumes that all distances are in meter units
|
||||||
void sendEditParticleMessage(PACKET_TYPE type, ParticleID particleID, const ParticleProperties& properties);
|
void sendEditParticleMessage(PACKET_TYPE type, ParticleID particleID, const ParticleProperties& properties);
|
||||||
|
|
|
@ -250,7 +250,7 @@ void ScriptEngine::run() {
|
||||||
|
|
||||||
int numAvatarPacketBytes = _avatarData->getBroadcastData(avatarPacket + numAvatarHeaderBytes) + numAvatarHeaderBytes;
|
int numAvatarPacketBytes = _avatarData->getBroadcastData(avatarPacket + numAvatarHeaderBytes) + numAvatarHeaderBytes;
|
||||||
|
|
||||||
nodeList->broadcastToNodes(avatarPacket, numAvatarPacketBytes, &NODE_TYPE_AVATAR_MIXER, 1);
|
nodeList->broadcastToNodes(avatarPacket, numAvatarPacketBytes, QSet<NODE_TYPE>() << NODE_TYPE_AVATAR_MIXER);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (willSendVisualDataCallBack) {
|
if (willSendVisualDataCallBack) {
|
||||||
|
|
|
@ -669,12 +669,13 @@ SharedNodePointer NodeList::addOrUpdateNode(const QUuid& uuid, char nodeType,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned NodeList::broadcastToNodes(unsigned char* broadcastData, size_t dataBytes, const char* nodeTypes, int numNodeTypes) {
|
unsigned NodeList::broadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||||
|
const QSet<NODE_TYPE>& destinationNodeTypes) {
|
||||||
unsigned n = 0;
|
unsigned n = 0;
|
||||||
|
|
||||||
foreach (const SharedNodePointer& node, getNodeHash()) {
|
foreach (const SharedNodePointer& node, getNodeHash()) {
|
||||||
// only send to the NodeTypes we are asked to send to.
|
// only send to the NodeTypes we are asked to send to.
|
||||||
if (memchr(nodeTypes, node->getType(), numNodeTypes)) {
|
if (destinationNodeTypes.contains(node->getType())) {
|
||||||
if (getNodeActiveSocketOrPing(node.data())) {
|
if (getNodeActiveSocketOrPing(node.data())) {
|
||||||
// we know which socket is good for this node, send there
|
// we know which socket is good for this node, send there
|
||||||
_nodeSocket.writeDatagram((char*) broadcastData, dataBytes,
|
_nodeSocket.writeDatagram((char*) broadcastData, dataBytes,
|
||||||
|
|
|
@ -90,6 +90,7 @@ public:
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
const QSet<NODE_TYPE>& getNodeInterestSet() const { return _nodeTypesOfInterest; }
|
||||||
void addNodeTypeToInterestSet(NODE_TYPE nodeTypeToAdd);
|
void addNodeTypeToInterestSet(NODE_TYPE nodeTypeToAdd);
|
||||||
void addSetOfNodeTypesToNodeInterestSet(const QSet<NODE_TYPE>& setOfNodeTypes);
|
void addSetOfNodeTypesToNodeInterestSet(const QSet<NODE_TYPE>& setOfNodeTypes);
|
||||||
|
|
||||||
|
@ -115,7 +116,7 @@ public:
|
||||||
|
|
||||||
int updateNodeWithData(Node *node, const HifiSockAddr& senderSockAddr, unsigned char *packetData, int dataBytes);
|
int updateNodeWithData(Node *node, const HifiSockAddr& senderSockAddr, unsigned char *packetData, int dataBytes);
|
||||||
|
|
||||||
unsigned broadcastToNodes(unsigned char *broadcastData, size_t dataBytes, const char* nodeTypes, int numNodeTypes);
|
unsigned broadcastToNodes(unsigned char *broadcastData, size_t dataBytes, const QSet<NODE_TYPE>& destinationNodeTypes);
|
||||||
SharedNodePointer soloNodeOfType(char nodeType);
|
SharedNodePointer soloNodeOfType(char nodeType);
|
||||||
|
|
||||||
void loadData(QSettings* settings);
|
void loadData(QSettings* settings);
|
||||||
|
|
|
@ -27,13 +27,12 @@ const int PacketSender::MINIMAL_SLEEP_INTERVAL = (USECS_PER_SECOND / TARGET_FPS)
|
||||||
|
|
||||||
const int AVERAGE_CALL_TIME_SAMPLES = 10;
|
const int AVERAGE_CALL_TIME_SAMPLES = 10;
|
||||||
|
|
||||||
PacketSender::PacketSender(PacketSenderNotify* notify, int packetsPerSecond) :
|
PacketSender::PacketSender(int packetsPerSecond) :
|
||||||
_packetsPerSecond(packetsPerSecond),
|
_packetsPerSecond(packetsPerSecond),
|
||||||
_usecsPerProcessCallHint(0),
|
_usecsPerProcessCallHint(0),
|
||||||
_lastProcessCallTime(0),
|
_lastProcessCallTime(0),
|
||||||
_averageProcessCallTime(AVERAGE_CALL_TIME_SAMPLES),
|
_averageProcessCallTime(AVERAGE_CALL_TIME_SAMPLES),
|
||||||
_lastSendTime(0), // Note: we set this to 0 to indicate we haven't yet sent something
|
_lastSendTime(0), // Note: we set this to 0 to indicate we haven't yet sent something
|
||||||
_notify(notify),
|
|
||||||
_lastPPSCheck(0),
|
_lastPPSCheck(0),
|
||||||
_packetsOverCheckInterval(0),
|
_packetsOverCheckInterval(0),
|
||||||
_started(usecTimestampNow()),
|
_started(usecTimestampNow()),
|
||||||
|
@ -272,9 +271,8 @@ bool PacketSender::nonThreadedProcess() {
|
||||||
_totalPacketsSent++;
|
_totalPacketsSent++;
|
||||||
_totalBytesSent += temporary.getLength();
|
_totalBytesSent += temporary.getLength();
|
||||||
|
|
||||||
if (_notify) {
|
emit packetSent(temporary.getLength());
|
||||||
_notify->packetSentNotification(temporary.getLength());
|
|
||||||
}
|
|
||||||
_lastSendTime = now;
|
_lastSendTime = now;
|
||||||
}
|
}
|
||||||
return isStillRunning();
|
return isStillRunning();
|
||||||
|
|
|
@ -15,15 +15,9 @@
|
||||||
#include "NetworkPacket.h"
|
#include "NetworkPacket.h"
|
||||||
#include "SharedUtil.h"
|
#include "SharedUtil.h"
|
||||||
|
|
||||||
/// Notification Hook for packets being sent by a PacketSender
|
|
||||||
class PacketSenderNotify {
|
|
||||||
public:
|
|
||||||
virtual void packetSentNotification(ssize_t length) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/// Generalized threaded processor for queueing and sending of outbound packets.
|
/// Generalized threaded processor for queueing and sending of outbound packets.
|
||||||
class PacketSender : public GenericThread {
|
class PacketSender : public GenericThread {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static const uint64_t USECS_PER_SECOND;
|
static const uint64_t USECS_PER_SECOND;
|
||||||
|
@ -35,7 +29,7 @@ public:
|
||||||
static const int MINIMUM_PACKETS_PER_SECOND;
|
static const int MINIMUM_PACKETS_PER_SECOND;
|
||||||
static const int MINIMAL_SLEEP_INTERVAL;
|
static const int MINIMAL_SLEEP_INTERVAL;
|
||||||
|
|
||||||
PacketSender(PacketSenderNotify* notify = NULL, int packetsPerSecond = DEFAULT_PACKETS_PER_SECOND);
|
PacketSender(int packetsPerSecond = DEFAULT_PACKETS_PER_SECOND);
|
||||||
~PacketSender();
|
~PacketSender();
|
||||||
|
|
||||||
/// Add packet to outbound queue.
|
/// Add packet to outbound queue.
|
||||||
|
@ -48,9 +42,6 @@ public:
|
||||||
void setPacketsPerSecond(int packetsPerSecond);
|
void setPacketsPerSecond(int packetsPerSecond);
|
||||||
int getPacketsPerSecond() const { return _packetsPerSecond; }
|
int getPacketsPerSecond() const { return _packetsPerSecond; }
|
||||||
|
|
||||||
void setPacketSenderNotify(PacketSenderNotify* notify) { _notify = notify; }
|
|
||||||
PacketSenderNotify* getPacketSenderNotify() const { return _notify; }
|
|
||||||
|
|
||||||
virtual bool process();
|
virtual bool process();
|
||||||
|
|
||||||
/// are there packets waiting in the send queue to be sent
|
/// are there packets waiting in the send queue to be sent
|
||||||
|
@ -97,7 +88,8 @@ public:
|
||||||
|
|
||||||
/// returns the total bytes queued by this object over its lifetime
|
/// returns the total bytes queued by this object over its lifetime
|
||||||
uint64_t getLifetimeBytesQueued() const { return _totalBytesQueued; }
|
uint64_t getLifetimeBytesQueued() const { return _totalBytesQueued; }
|
||||||
|
signals:
|
||||||
|
void packetSent(quint64);
|
||||||
protected:
|
protected:
|
||||||
int _packetsPerSecond;
|
int _packetsPerSecond;
|
||||||
int _usecsPerProcessCallHint;
|
int _usecsPerProcessCallHint;
|
||||||
|
@ -107,7 +99,6 @@ protected:
|
||||||
private:
|
private:
|
||||||
std::vector<NetworkPacket> _packets;
|
std::vector<NetworkPacket> _packets;
|
||||||
uint64_t _lastSendTime;
|
uint64_t _lastSendTime;
|
||||||
PacketSenderNotify* _notify;
|
|
||||||
|
|
||||||
bool threadedProcess();
|
bool threadedProcess();
|
||||||
bool nonThreadedProcess();
|
bool nonThreadedProcess();
|
||||||
|
|
|
@ -15,10 +15,8 @@
|
||||||
|
|
||||||
/// Utility for processing, packing, queueing and sending of outbound edit voxel messages.
|
/// Utility for processing, packing, queueing and sending of outbound edit voxel messages.
|
||||||
class VoxelEditPacketSender : public OctreeEditPacketSender {
|
class VoxelEditPacketSender : public OctreeEditPacketSender {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VoxelEditPacketSender(PacketSenderNotify* notify = NULL) : OctreeEditPacketSender(notify) { }
|
|
||||||
~VoxelEditPacketSender() { }
|
|
||||||
|
|
||||||
/// Send voxel edit message immediately
|
/// Send voxel edit message immediately
|
||||||
void sendVoxelEditMessage(PACKET_TYPE type, VoxelDetail& detail);
|
void sendVoxelEditMessage(PACKET_TYPE type, VoxelDetail& detail);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue