mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 09:44:21 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into metavoxels
This commit is contained in:
commit
e6c1aad71f
19 changed files with 66 additions and 78 deletions
|
@ -132,9 +132,9 @@ void AvatarMixer::processDatagram(const QByteArray& dataByteArray, const HifiSoc
|
|||
// parse positional data from an node
|
||||
nodeList->updateNodeWithData(avatarNode.data(), senderSockAddr,
|
||||
(unsigned char*) dataByteArray.data(), dataByteArray.size());
|
||||
} else {
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PACKET_TYPE_KILL_NODE:
|
||||
default:
|
||||
|
|
|
@ -145,8 +145,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
_enableProcessVoxelsThread(true),
|
||||
_voxelProcessor(),
|
||||
_voxelHideShowThread(&_voxels),
|
||||
_voxelEditSender(this),
|
||||
_particleEditSender(this),
|
||||
_packetsPerSecond(0),
|
||||
_bytesPerSecond(0),
|
||||
_recentMaxPackets(0),
|
||||
|
@ -234,6 +232,10 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
nodeList->addSetOfNodeTypesToNodeInterestSet(QSet<NODE_TYPE>() << NODE_TYPE_AUDIO_MIXER << NODE_TYPE_AVATAR_MIXER
|
||||
<< NODE_TYPE_VOXEL_SERVER << NODE_TYPE_PARTICLE_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
|
||||
QTimer* silentNodeTimer = new QTimer();
|
||||
|
@ -292,7 +294,7 @@ Application::~Application() {
|
|||
_settings->sync();
|
||||
|
||||
// let the avatar mixer know we're out
|
||||
NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);
|
||||
NodeList::getInstance()->sendKillNode(QSet<NODE_TYPE>() << NODE_TYPE_AVATAR_MIXER);
|
||||
|
||||
// ask the datagram processing thread to quit and wait until it is done
|
||||
_nodeThread->quit();
|
||||
|
@ -643,21 +645,20 @@ void Application::resetProfile(const QString& username) {
|
|||
}
|
||||
|
||||
void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||
const char* nodeTypes, int numNodeTypes) {
|
||||
Application* self = getInstance();
|
||||
for (int i = 0; i < numNodeTypes; ++i) {
|
||||
|
||||
const QSet<NODE_TYPE>& destinationNodeTypes) {
|
||||
foreach(NODE_TYPE type, destinationNodeTypes) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
// 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)
|
||||
BandwidthMeter::ChannelIndex channel;
|
||||
switch (nodeTypes[i]) {
|
||||
switch (type) {
|
||||
case NODE_TYPE_AGENT:
|
||||
case NODE_TYPE_AVATAR_MIXER:
|
||||
channel = BandwidthMeter::AVATARS;
|
||||
|
@ -668,7 +669,7 @@ void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_
|
|||
default:
|
||||
continue;
|
||||
}
|
||||
self->_bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * dataBytes);
|
||||
_bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * dataBytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1322,15 +1323,13 @@ void Application::wheelEvent(QWheelEvent* event) {
|
|||
}
|
||||
|
||||
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];
|
||||
int length = NodeList::getInstance()->fillPingPacket(pingPacket);
|
||||
|
||||
getInstance()->controlledBroadcastToNodes(pingPacket, length,
|
||||
nodesToPing, sizeof(nodesToPing));
|
||||
getInstance()->controlledBroadcastToNodes(pingPacket, length, QSet<NODE_TYPE>()
|
||||
<< 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
|
||||
|
@ -2446,9 +2445,8 @@ void Application::updateAvatar(float deltaTime) {
|
|||
|
||||
endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite);
|
||||
|
||||
const char nodeTypesOfInterest[] = { NODE_TYPE_AVATAR_MIXER };
|
||||
controlledBroadcastToNodes(broadcastString, endOfBroadcastStringWrite - broadcastString,
|
||||
nodeTypesOfInterest, sizeof(nodeTypesOfInterest));
|
||||
QSet<NODE_TYPE>() << NODE_TYPE_AVATAR_MIXER);
|
||||
|
||||
// Update _viewFrustum with latest camera and view frustum data...
|
||||
// NOTE: we get this from the view frustum, to make it simpler, since the
|
||||
|
@ -4052,7 +4050,7 @@ int Application::parseOctreeStats(unsigned char* messageData, ssize_t messageLen
|
|||
return statsMessageLength;
|
||||
}
|
||||
|
||||
void Application::packetSentNotification(ssize_t length) {
|
||||
void Application::packetSent(quint64 length) {
|
||||
_bandwidthMeter.outputStream(BandwidthMeter::VOXELS).updateValue(length);
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ static const float NODE_KILLED_RED = 1.0f;
|
|||
static const float NODE_KILLED_GREEN = 0.0f;
|
||||
static const float NODE_KILLED_BLUE = 0.0f;
|
||||
|
||||
class Application : public QApplication, public PacketSenderNotify {
|
||||
class Application : public QApplication {
|
||||
Q_OBJECT
|
||||
|
||||
friend class VoxelPacketProcessor;
|
||||
|
@ -174,8 +174,8 @@ public:
|
|||
Profile* getProfile() { return &_profile; }
|
||||
void resetProfile(const QString& username);
|
||||
|
||||
static void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||
const char* nodeTypes, int numNodeTypes);
|
||||
void controlledBroadcastToNodes(unsigned char* broadcastData, size_t dataBytes,
|
||||
const QSet<NODE_TYPE>& destinationNodeTypes);
|
||||
|
||||
void setupWorldLight();
|
||||
|
||||
|
@ -191,9 +191,6 @@ public:
|
|||
void computeOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
||||
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane) const;
|
||||
|
||||
|
||||
virtual void packetSentNotification(ssize_t length);
|
||||
|
||||
VoxelShader& getVoxelShader() { return _voxelShader; }
|
||||
PointShader& getPointShader() { return _pointShader; }
|
||||
FileLogger* getLogger() { return _logger; }
|
||||
|
@ -217,7 +214,8 @@ signals:
|
|||
public slots:
|
||||
void domainChanged(const QString& domainHostname);
|
||||
void nodeKilled(SharedNodePointer node);
|
||||
|
||||
void packetSent(quint64 length);
|
||||
|
||||
void exportVoxels();
|
||||
void importVoxels();
|
||||
void cutVoxels();
|
||||
|
|
|
@ -902,7 +902,7 @@ void Menu::goToDomain() {
|
|||
}
|
||||
|
||||
// send a node kill request, indicating to other clients that they should play the "disappeared" effect
|
||||
NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);
|
||||
NodeList::getInstance()->sendKillNode(QSet<NODE_TYPE>() << NODE_TYPE_AVATAR_MIXER);
|
||||
|
||||
// give our nodeList the new domain-server hostname
|
||||
NodeList::getInstance()->setDomainHostname(domainDialog.textValue());
|
||||
|
@ -944,7 +944,7 @@ void Menu::goToLocation() {
|
|||
|
||||
if (newAvatarPos != avatarPos) {
|
||||
// send a node kill request, indicating to other clients that they should play the "disappeared" effect
|
||||
NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);
|
||||
NodeList::getInstance()->sendKillNode(QSet<NODE_TYPE>() << NODE_TYPE_AVATAR_MIXER);
|
||||
|
||||
qDebug("Going To Location: %f, %f, %f...", x, y, z);
|
||||
myAvatar->setPosition(newAvatarPos);
|
||||
|
|
|
@ -198,7 +198,7 @@ void Profile::processDataServerResponse(const QString& userString, const QString
|
|||
if (coordinateItems.size() == 3 && orientationItems.size() == 3) {
|
||||
|
||||
// send a node kill request, indicating to other clients that they should play the "disappeared" effect
|
||||
NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);
|
||||
NodeList::getInstance()->sendKillNode(QSet<NODE_TYPE>() << NODE_TYPE_AVATAR_MIXER);
|
||||
|
||||
qDebug() << "Changing domain to" << valueList[i].toLocal8Bit().constData() <<
|
||||
", position to" << valueList[i + 1].toLocal8Bit().constData() <<
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
#include <PacketHeaders.h>
|
||||
#include "JurisdictionListener.h"
|
||||
|
||||
JurisdictionListener::JurisdictionListener(NODE_TYPE type, PacketSenderNotify* notify) :
|
||||
_packetSender(notify, JurisdictionListener::DEFAULT_PACKETS_PER_SECOND)
|
||||
JurisdictionListener::JurisdictionListener(NODE_TYPE type) :
|
||||
_packetSender(JurisdictionListener::DEFAULT_PACKETS_PER_SECOND)
|
||||
{
|
||||
_nodeType = type;
|
||||
ReceivedPacketProcessor::_dontSleep = true; // we handle sleeping so this class doesn't need to
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
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
|
||||
|
||||
JurisdictionListener(NODE_TYPE type = NODE_TYPE_VOXEL_SERVER, PacketSenderNotify* notify = NULL);
|
||||
JurisdictionListener(NODE_TYPE type = NODE_TYPE_VOXEL_SERVER);
|
||||
|
||||
virtual bool process();
|
||||
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
#include "JurisdictionSender.h"
|
||||
|
||||
|
||||
JurisdictionSender::JurisdictionSender(JurisdictionMap* map, NODE_TYPE type, PacketSenderNotify* notify) :
|
||||
JurisdictionSender::JurisdictionSender(JurisdictionMap* map, NODE_TYPE type) :
|
||||
ReceivedPacketProcessor(),
|
||||
_jurisdictionMap(map),
|
||||
_packetSender(notify, JurisdictionSender::DEFAULT_PACKETS_PER_SECOND)
|
||||
_packetSender(JurisdictionSender::DEFAULT_PACKETS_PER_SECOND)
|
||||
{
|
||||
_nodeType = type;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class JurisdictionSender : public ReceivedPacketProcessor {
|
|||
public:
|
||||
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();
|
||||
|
||||
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;
|
||||
|
||||
|
||||
OctreeEditPacketSender::OctreeEditPacketSender(PacketSenderNotify* notify) :
|
||||
PacketSender(notify),
|
||||
OctreeEditPacketSender::OctreeEditPacketSender() :
|
||||
PacketSender(),
|
||||
_shouldSend(true),
|
||||
_maxPendingMessages(DEFAULT_MAX_PENDING_MESSAGES),
|
||||
_releaseQueuedMessagesPending(false),
|
||||
|
|
|
@ -28,8 +28,9 @@ public:
|
|||
|
||||
/// Utility for processing, packing, queueing and sending of outbound edit messages.
|
||||
class OctreeEditPacketSender : public PacketSender {
|
||||
Q_OBJECT
|
||||
public:
|
||||
OctreeEditPacketSender(PacketSenderNotify* notify = NULL);
|
||||
OctreeEditPacketSender();
|
||||
~OctreeEditPacketSender();
|
||||
|
||||
/// 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.
|
||||
class ParticleEditPacketSender : public OctreeEditPacketSender {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ParticleEditPacketSender(PacketSenderNotify* notify = NULL) : OctreeEditPacketSender(notify) { }
|
||||
~ParticleEditPacketSender() { }
|
||||
|
||||
/// Send particle add message immediately
|
||||
/// NOTE: ParticleProperties assumes that all distances are in meter units
|
||||
void sendEditParticleMessage(PACKET_TYPE type, ParticleID particleID, const ParticleProperties& properties);
|
||||
|
|
|
@ -250,7 +250,7 @@ void ScriptEngine::run() {
|
|||
|
||||
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) {
|
||||
|
|
|
@ -20,7 +20,10 @@ GenericThread::GenericThread() :
|
|||
}
|
||||
|
||||
GenericThread::~GenericThread() {
|
||||
terminate();
|
||||
// we only need to call terminate() if we're actually threaded and still running
|
||||
if (isStillRunning() && isThreaded()) {
|
||||
terminate();
|
||||
}
|
||||
}
|
||||
|
||||
void GenericThread::initialize(bool isThreaded) {
|
||||
|
@ -45,6 +48,7 @@ void GenericThread::terminate() {
|
|||
if (_thread) {
|
||||
_thread->wait();
|
||||
_thread->deleteLater();
|
||||
_thread = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ NodeList* NodeList::getInstance() {
|
|||
|
||||
NodeList::NodeList(char newOwnerType, unsigned short int newSocketListenPort) :
|
||||
_nodeHash(),
|
||||
_nodeHashMutex(),
|
||||
_nodeHashMutex(QMutex::Recursive),
|
||||
_domainHostname(DEFAULT_DOMAIN_HOSTNAME),
|
||||
_domainSockAddr(HifiSockAddr(QHostAddress::Null, DEFAULT_DOMAIN_SERVER_PORT)),
|
||||
_nodeSocket(this),
|
||||
|
@ -233,7 +233,7 @@ int NodeList::updateNodeWithData(Node *node, const HifiSockAddr& senderSockAddr,
|
|||
|
||||
node->setLastHeardMicrostamp(usecTimestampNow());
|
||||
|
||||
if (!senderSockAddr.isNull()) {
|
||||
if (!senderSockAddr.isNull() && !node->getActiveSocket()) {
|
||||
if (senderSockAddr == node->getPublicSocket()) {
|
||||
node->activatePublicSocket();
|
||||
} else if (senderSockAddr == node->getLocalSocket()) {
|
||||
|
@ -460,7 +460,7 @@ NodeHash::iterator NodeList::killNodeAtHashIterator(NodeHash::iterator& nodeItem
|
|||
return _nodeHash.erase(nodeItemToKill);
|
||||
}
|
||||
|
||||
void NodeList::sendKillNode(const char* nodeTypes, int numNodeTypes) {
|
||||
void NodeList::sendKillNode(const QSet<NODE_TYPE>& destinationNodeTypes) {
|
||||
unsigned char packet[MAX_PACKET_SIZE];
|
||||
unsigned char* packetPosition = packet;
|
||||
|
||||
|
@ -470,7 +470,7 @@ void NodeList::sendKillNode(const char* nodeTypes, int numNodeTypes) {
|
|||
memcpy(packetPosition, rfcUUID.constData(), rfcUUID.size());
|
||||
packetPosition += rfcUUID.size();
|
||||
|
||||
broadcastToNodes(packet, packetPosition - packet, nodeTypes, numNodeTypes);
|
||||
broadcastToNodes(packet, packetPosition - packet, destinationNodeTypes);
|
||||
}
|
||||
|
||||
void NodeList::processKillNode(unsigned char* packetData, size_t dataBytes) {
|
||||
|
@ -733,12 +733,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;
|
||||
|
||||
foreach (const SharedNodePointer& node, getNodeHash()) {
|
||||
// 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())) {
|
||||
// we know which socket is good for this node, send there
|
||||
_nodeSocket.writeDatagram((char*) broadcastData, dataBytes,
|
||||
|
|
|
@ -90,6 +90,7 @@ public:
|
|||
|
||||
void reset();
|
||||
|
||||
const QSet<NODE_TYPE>& getNodeInterestSet() const { return _nodeTypesOfInterest; }
|
||||
void addNodeTypeToInterestSet(NODE_TYPE nodeTypeToAdd);
|
||||
void addSetOfNodeTypesToNodeInterestSet(const QSet<NODE_TYPE>& setOfNodeTypes);
|
||||
|
||||
|
@ -104,7 +105,7 @@ public:
|
|||
int fillPingReplyPacket(unsigned char* pingBuffer, unsigned char* replyBuffer);
|
||||
void pingPublicAndLocalSocketsForInactiveNode(Node* node);
|
||||
|
||||
void sendKillNode(const char* nodeTypes, int numNodeTypes);
|
||||
void sendKillNode(const QSet<NODE_TYPE>& destinationNodeTypes);
|
||||
|
||||
SharedNodePointer nodeWithAddress(const HifiSockAddr& senderSockAddr);
|
||||
SharedNodePointer nodeWithUUID(const QUuid& nodeUUID);
|
||||
|
@ -116,7 +117,7 @@ public:
|
|||
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
PacketSender::PacketSender(PacketSenderNotify* notify, int packetsPerSecond) :
|
||||
PacketSender::PacketSender(int packetsPerSecond) :
|
||||
_packetsPerSecond(packetsPerSecond),
|
||||
_usecsPerProcessCallHint(0),
|
||||
_lastProcessCallTime(0),
|
||||
_averageProcessCallTime(AVERAGE_CALL_TIME_SAMPLES),
|
||||
_lastSendTime(0), // Note: we set this to 0 to indicate we haven't yet sent something
|
||||
_notify(notify),
|
||||
_lastPPSCheck(0),
|
||||
_packetsOverCheckInterval(0),
|
||||
_started(usecTimestampNow()),
|
||||
|
@ -271,10 +270,9 @@ bool PacketSender::nonThreadedProcess() {
|
|||
_packetsOverCheckInterval++;
|
||||
_totalPacketsSent++;
|
||||
_totalBytesSent += temporary.getLength();
|
||||
|
||||
if (_notify) {
|
||||
_notify->packetSentNotification(temporary.getLength());
|
||||
}
|
||||
|
||||
emit packetSent(temporary.getLength());
|
||||
|
||||
_lastSendTime = now;
|
||||
}
|
||||
return isStillRunning();
|
||||
|
|
|
@ -15,15 +15,9 @@
|
|||
#include "NetworkPacket.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.
|
||||
class PacketSender : public GenericThread {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
static const uint64_t USECS_PER_SECOND;
|
||||
|
@ -35,7 +29,7 @@ public:
|
|||
static const int MINIMUM_PACKETS_PER_SECOND;
|
||||
static const int MINIMAL_SLEEP_INTERVAL;
|
||||
|
||||
PacketSender(PacketSenderNotify* notify = NULL, int packetsPerSecond = DEFAULT_PACKETS_PER_SECOND);
|
||||
PacketSender(int packetsPerSecond = DEFAULT_PACKETS_PER_SECOND);
|
||||
~PacketSender();
|
||||
|
||||
/// Add packet to outbound queue.
|
||||
|
@ -48,9 +42,6 @@ public:
|
|||
void setPacketsPerSecond(int packetsPerSecond);
|
||||
int getPacketsPerSecond() const { return _packetsPerSecond; }
|
||||
|
||||
void setPacketSenderNotify(PacketSenderNotify* notify) { _notify = notify; }
|
||||
PacketSenderNotify* getPacketSenderNotify() const { return _notify; }
|
||||
|
||||
virtual bool process();
|
||||
|
||||
/// 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
|
||||
uint64_t getLifetimeBytesQueued() const { return _totalBytesQueued; }
|
||||
|
||||
signals:
|
||||
void packetSent(quint64);
|
||||
protected:
|
||||
int _packetsPerSecond;
|
||||
int _usecsPerProcessCallHint;
|
||||
|
@ -107,7 +99,6 @@ protected:
|
|||
private:
|
||||
std::vector<NetworkPacket> _packets;
|
||||
uint64_t _lastSendTime;
|
||||
PacketSenderNotify* _notify;
|
||||
|
||||
bool threadedProcess();
|
||||
bool nonThreadedProcess();
|
||||
|
|
|
@ -15,10 +15,8 @@
|
|||
|
||||
/// Utility for processing, packing, queueing and sending of outbound edit voxel messages.
|
||||
class VoxelEditPacketSender : public OctreeEditPacketSender {
|
||||
Q_OBJECT
|
||||
public:
|
||||
VoxelEditPacketSender(PacketSenderNotify* notify = NULL) : OctreeEditPacketSender(notify) { }
|
||||
~VoxelEditPacketSender() { }
|
||||
|
||||
/// Send voxel edit message immediately
|
||||
void sendVoxelEditMessage(PACKET_TYPE type, VoxelDetail& detail);
|
||||
|
||||
|
|
Loading…
Reference in a new issue