mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 12:13:40 +02:00
kill the PacketLister (AKA Huffman 1 : PacketListener 0)
This commit is contained in:
parent
e7249594e1
commit
7d60b86f52
17 changed files with 41 additions and 99 deletions
assignment-client/src
domain-server/src
interface/src
libraries
audio-client/src
avatars/src
entities/src
networking/src
|
@ -15,13 +15,11 @@
|
|||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QPointer>
|
||||
|
||||
#include <PacketListener.h>
|
||||
|
||||
#include "ThreadedAssignment.h"
|
||||
|
||||
class QSharedMemory;
|
||||
|
||||
class AssignmentClient : public QObject, public PacketListener {
|
||||
class AssignmentClient : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
AssignmentClient(Assignment::Type requestAssignmentType, QString assignmentPool,
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
|
||||
extern const char* NUM_FORKS_PARAMETER;
|
||||
|
||||
|
||||
class AssignmentClientMonitor : public QObject, public PacketListener {
|
||||
class AssignmentClientMonitor : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
AssignmentClientMonitor(const unsigned int numAssignmentClientForks, const unsigned int minAssignmentClientForks,
|
||||
|
|
|
@ -341,6 +341,9 @@ void AvatarMixer::broadcastAvatarData() {
|
|||
++_sumIdentityPackets;
|
||||
}
|
||||
});
|
||||
|
||||
// close the current packet so that we're always sending something
|
||||
avatarPacketList.closeCurrentPacket(true);
|
||||
|
||||
// send the avatar data PacketList
|
||||
nodeList->sendPacketList(avatarPacketList, *node);
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <Assignment.h>
|
||||
#include <HTTPSConnection.h>
|
||||
#include <LimitedNodeList.h>
|
||||
#include <PacketListener.h>
|
||||
|
||||
#include "DomainServerSettingsManager.h"
|
||||
#include "DomainServerWebSessionData.h"
|
||||
|
@ -35,7 +34,7 @@
|
|||
typedef QSharedPointer<Assignment> SharedAssignmentPointer;
|
||||
typedef QMultiHash<QUuid, WalletTransaction*> TransactionHash;
|
||||
|
||||
class DomainServer : public QCoreApplication, public HTTPSRequestHandler, public PacketListener {
|
||||
class DomainServer : public QCoreApplication, public HTTPSRequestHandler {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DomainServer(int argc, char* argv[]);
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <OctreeQuery.h>
|
||||
#include <OffscreenUi.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <PacketListener.h>
|
||||
#include <PhysicalEntitySimulation.h>
|
||||
#include <PhysicsEngine.h>
|
||||
#include <ScriptEngine.h>
|
||||
|
@ -126,11 +125,7 @@ class Application;
|
|||
|
||||
typedef bool (Application::* AcceptURLMethod)(const QString &);
|
||||
|
||||
class Application :
|
||||
public QApplication,
|
||||
public AbstractViewStateInterface,
|
||||
public AbstractScriptingServicesInterface,
|
||||
public PacketListener {
|
||||
class Application : public QApplication, public AbstractViewStateInterface, public AbstractScriptingServicesInterface {
|
||||
Q_OBJECT
|
||||
|
||||
friend class OctreePacketProcessor;
|
||||
|
|
|
@ -13,11 +13,10 @@
|
|||
#define hifi_OctreePacketProcessor_h
|
||||
|
||||
#include <ReceivedPacketProcessor.h>
|
||||
#include <PacketListener.h>
|
||||
|
||||
/// Handles processing of incoming voxel packets for the interface application. As with other ReceivedPacketProcessor classes
|
||||
/// the user is responsible for reading inbound packets and adding them to the processing queue by calling queueReceivedPacket()
|
||||
class OctreePacketProcessor : public ReceivedPacketProcessor, public PacketListener {
|
||||
class OctreePacketProcessor : public ReceivedPacketProcessor {
|
||||
Q_OBJECT
|
||||
public:
|
||||
OctreePacketProcessor();
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include <NLPacket.h>
|
||||
#include <MixedProcessedAudioStream.h>
|
||||
#include <RingBufferHistory.h>
|
||||
#include <PacketListener.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <Sound.h>
|
||||
#include <StDev.h>
|
||||
|
@ -81,7 +80,7 @@ typedef glm::quat (*AudioOrientationGetter)();
|
|||
|
||||
class NLPacket;
|
||||
|
||||
class AudioClient : public AbstractAudioInterface, public Dependency, public PacketListener {
|
||||
class AudioClient : public AbstractAudioInterface, public Dependency {
|
||||
Q_OBJECT
|
||||
SINGLETON_DEPENDENCY
|
||||
public:
|
||||
|
|
|
@ -19,11 +19,10 @@
|
|||
#include <AudioStreamStats.h>
|
||||
#include <Node.h>
|
||||
#include <NLPacket.h>
|
||||
#include <PacketListener.h>
|
||||
|
||||
class MixedProcessedAudioStream;
|
||||
|
||||
class AudioIOStats : public QObject, public PacketListener {
|
||||
class AudioIOStats : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
AudioIOStats(MixedProcessedAudioStream* receivedAudioStream);
|
||||
|
|
|
@ -21,12 +21,11 @@
|
|||
#include <DependencyManager.h>
|
||||
#include <NLPacket.h>
|
||||
#include <Node.h>
|
||||
#include <PacketListener.h>
|
||||
|
||||
#include "AvatarData.h"
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
class AvatarHashMap : public QObject, public Dependency, public PacketListener {
|
||||
class AvatarHashMap : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
SINGLETON_DEPENDENCY
|
||||
|
||||
|
|
|
@ -14,12 +14,10 @@
|
|||
|
||||
#include <OctreeEditPacketSender.h>
|
||||
|
||||
#include <PacketListener.h>
|
||||
|
||||
#include "EntityItem.h"
|
||||
|
||||
/// Utility for processing, packing, queueing and sending of outbound edit voxel messages.
|
||||
class EntityEditPacketSender : public OctreeEditPacketSender, public PacketListener {
|
||||
class EntityEditPacketSender : public OctreeEditPacketSender {
|
||||
Q_OBJECT
|
||||
public:
|
||||
EntityEditPacketSender();
|
||||
|
|
|
@ -22,14 +22,13 @@
|
|||
#include "HifiSockAddr.h"
|
||||
#include "NetworkPeer.h"
|
||||
#include "NLPacket.h"
|
||||
#include "PacketListener.h"
|
||||
|
||||
const unsigned short DEFAULT_DOMAIN_SERVER_PORT = 40102;
|
||||
const unsigned short DEFAULT_DOMAIN_SERVER_DTLS_PORT = 40103;
|
||||
const quint16 DOMAIN_SERVER_HTTP_PORT = 40100;
|
||||
const quint16 DOMAIN_SERVER_HTTPS_PORT = 40101;
|
||||
|
||||
class DomainHandler : public QObject, public PacketListener {
|
||||
class DomainHandler : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DomainHandler(QObject* parent = 0);
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "NLPacket.h"
|
||||
#include "udt/PacketHeaders.h"
|
||||
#include "PacketReceiver.h"
|
||||
#include "PacketListener.h"
|
||||
#include "NLPacketList.h"
|
||||
#include "UUIDHasher.h"
|
||||
|
||||
|
@ -74,7 +73,7 @@ namespace PingType {
|
|||
const PingType_t Symmetric = 3;
|
||||
}
|
||||
|
||||
class LimitedNodeList : public QObject, public Dependency, public PacketListener {
|
||||
class LimitedNodeList : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
SINGLETON_DEPENDENCY
|
||||
public:
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
//
|
||||
// PacketListener.cpp
|
||||
// libraries/networking/src
|
||||
//
|
||||
// Created by Stephen Birarda on 07/14/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "PacketListener.h"
|
||||
|
||||
#include "NodeList.h"
|
||||
|
||||
PacketListener::~PacketListener() {
|
||||
auto limitedNodelist = DependencyManager::get<LimitedNodeList>();
|
||||
if (limitedNodelist) {
|
||||
limitedNodelist->getPacketReceiver().unregisterListener(this);
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
//
|
||||
// PacketListener.h
|
||||
// libraries/networking/src
|
||||
//
|
||||
// Created by Stephen Birarda on 07/14/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_PacketListener_h
|
||||
#define hifi_PacketListener_h
|
||||
|
||||
#pragma once
|
||||
|
||||
class PacketListener {
|
||||
public:
|
||||
virtual ~PacketListener();
|
||||
};
|
||||
|
||||
#endif // hifi_PacketListener_h
|
|
@ -24,7 +24,7 @@ PacketReceiver::PacketReceiver(QObject* parent) :
|
|||
qRegisterMetaType<QSharedPointer<NLPacket>>();
|
||||
}
|
||||
|
||||
bool PacketReceiver::registerListenerForTypes(const QSet<PacketType::Value>& types, PacketListener* listener, const char* slot) {
|
||||
bool PacketReceiver::registerListenerForTypes(const QSet<PacketType::Value>& types, QObject* listener, const char* slot) {
|
||||
QSet<PacketType::Value> nonSourcedTypes;
|
||||
QSet<PacketType::Value> sourcedTypes;
|
||||
|
||||
|
@ -36,14 +36,13 @@ bool PacketReceiver::registerListenerForTypes(const QSet<PacketType::Value>& typ
|
|||
}
|
||||
}
|
||||
|
||||
QObject* object = dynamic_cast<QObject*>(listener);
|
||||
Q_ASSERT(object);
|
||||
Q_ASSERT(listener);
|
||||
|
||||
if (nonSourcedTypes.size() > 0) {
|
||||
QMetaMethod nonSourcedMethod = matchingMethodForListener(*nonSourcedTypes.begin(), object, slot);
|
||||
QMetaMethod nonSourcedMethod = matchingMethodForListener(*nonSourcedTypes.begin(), listener, slot);
|
||||
if (nonSourcedMethod.isValid()) {
|
||||
foreach(PacketType::Value type, nonSourcedTypes) {
|
||||
registerVerifiedListener(type, object, nonSourcedMethod);
|
||||
registerVerifiedListener(type, listener, nonSourcedMethod);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
|
@ -51,10 +50,10 @@ bool PacketReceiver::registerListenerForTypes(const QSet<PacketType::Value>& typ
|
|||
}
|
||||
|
||||
if (sourcedTypes.size() > 0) {
|
||||
QMetaMethod sourcedMethod = matchingMethodForListener(*sourcedTypes.begin(), object, slot);
|
||||
QMetaMethod sourcedMethod = matchingMethodForListener(*sourcedTypes.begin(), listener, slot);
|
||||
if (sourcedMethod.isValid()) {
|
||||
foreach(PacketType::Value type, sourcedTypes) {
|
||||
registerVerifiedListener(type, object, sourcedMethod);
|
||||
registerVerifiedListener(type, listener, sourcedMethod);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
|
@ -66,7 +65,7 @@ bool PacketReceiver::registerListenerForTypes(const QSet<PacketType::Value>& typ
|
|||
|
||||
|
||||
void PacketReceiver::registerDirectListenerForTypes(const QSet<PacketType::Value>& types,
|
||||
PacketListener* listener, const char* slot) {
|
||||
QObject* listener, const char* slot) {
|
||||
// just call register listener for types to start
|
||||
bool success = registerListenerForTypes(types, listener, slot);
|
||||
if (success) {
|
||||
|
@ -79,14 +78,13 @@ void PacketReceiver::registerDirectListenerForTypes(const QSet<PacketType::Value
|
|||
}
|
||||
}
|
||||
|
||||
bool PacketReceiver::registerListener(PacketType::Value type, PacketListener* listener, const char* slot) {
|
||||
QObject* object = dynamic_cast<QObject*>(listener);
|
||||
Q_ASSERT(object);
|
||||
bool PacketReceiver::registerListener(PacketType::Value type, QObject* listener, const char* slot) {
|
||||
Q_ASSERT(listener);
|
||||
|
||||
QMetaMethod matchingMethod = matchingMethodForListener(type, object, slot);
|
||||
QMetaMethod matchingMethod = matchingMethodForListener(type, listener, slot);
|
||||
|
||||
if (matchingMethod.isValid()) {
|
||||
registerVerifiedListener(type, object, matchingMethod);
|
||||
registerVerifiedListener(type, listener, matchingMethod);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -156,21 +154,19 @@ void PacketReceiver::registerVerifiedListener(PacketType::Value type, QObject* o
|
|||
}
|
||||
|
||||
// add the mapping
|
||||
_packetListenerMap[type] = ObjectMethodPair(object, slot);
|
||||
_packetListenerMap[type] = ObjectMethodPair(QPointer<QObject>(object), slot);
|
||||
|
||||
_packetListenerLock.unlock();
|
||||
|
||||
}
|
||||
|
||||
void PacketReceiver::unregisterListener(PacketListener* listener) {
|
||||
QObject* listenerObject = dynamic_cast<QObject*>(listener);
|
||||
|
||||
void PacketReceiver::unregisterListener(QObject* listener) {
|
||||
_packetListenerLock.lock();
|
||||
|
||||
auto it = _packetListenerMap.begin();
|
||||
|
||||
while (it != _packetListenerMap.end()) {
|
||||
if (it.value().first == listenerObject) {
|
||||
if (it.value().first == listener) {
|
||||
// this listener matches - erase it
|
||||
it = _packetListenerMap.erase(it);
|
||||
} else {
|
||||
|
@ -181,7 +177,7 @@ void PacketReceiver::unregisterListener(PacketListener* listener) {
|
|||
_packetListenerLock.unlock();
|
||||
|
||||
_directConnectSetMutex.lock();
|
||||
_directlyConnectedObjects.remove(listenerObject);
|
||||
_directlyConnectedObjects.remove(listener);
|
||||
_directConnectSetMutex.unlock();
|
||||
}
|
||||
|
||||
|
@ -335,6 +331,11 @@ void PacketReceiver::processDatagrams() {
|
|||
<< listener.first << "::" << qPrintable(listener.second.methodSignature());
|
||||
}
|
||||
|
||||
} else {
|
||||
qDebug().nospace() << "Listener for packet" << packet->getType()
|
||||
<< " (" << qPrintable(nameForPacketType(packet->getType())) << ")"
|
||||
<< " has been destroyed. Removing from listener map.";
|
||||
it = _packetListenerMap.erase(it);
|
||||
}
|
||||
} else {
|
||||
qWarning() << "No listener found for packet type " << nameForPacketType(packet->getType());
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
#include <QtCore/QMetaMethod>
|
||||
#include <QtCore/QMutex>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtCore/QSet>
|
||||
|
||||
#include "NLPacket.h"
|
||||
#include "udt/PacketHeaders.h"
|
||||
|
||||
class OctreePacketProcessor;
|
||||
class PacketListener;
|
||||
|
||||
class PacketReceiver : public QObject {
|
||||
Q_OBJECT
|
||||
|
@ -40,9 +40,9 @@ public:
|
|||
|
||||
void resetCounters() { _inPacketCount = 0; _inByteCount = 0; }
|
||||
|
||||
bool registerListenerForTypes(const QSet<PacketType::Value>& types, PacketListener* listener, const char* slot);
|
||||
bool registerListener(PacketType::Value type, PacketListener* listener, const char* slot);
|
||||
void unregisterListener(PacketListener* listener);
|
||||
bool registerListenerForTypes(const QSet<PacketType::Value>& types, QObject* listener, const char* slot);
|
||||
bool registerListener(PacketType::Value type, QObject* listener, const char* slot);
|
||||
void unregisterListener(QObject* listener);
|
||||
|
||||
public slots:
|
||||
void processDatagrams();
|
||||
|
@ -55,14 +55,14 @@ signals:
|
|||
private:
|
||||
// this is a brutal hack for now - ideally GenericThread / ReceivedPacketProcessor
|
||||
// should be changed to have a true event loop and be able to handle our QMetaMethod::invoke
|
||||
void registerDirectListenerForTypes(const QSet<PacketType::Value>& types, PacketListener* listener, const char* slot);
|
||||
void registerDirectListenerForTypes(const QSet<PacketType::Value>& types, QObject* listener, const char* slot);
|
||||
|
||||
bool packetVersionMatch(const NLPacket& packet);
|
||||
|
||||
QMetaMethod matchingMethodForListener(PacketType::Value type, QObject* object, const char* slot) const;
|
||||
void registerVerifiedListener(PacketType::Value type, QObject* listener, const QMetaMethod& slot);
|
||||
|
||||
using ObjectMethodPair = std::pair<QObject*, QMetaMethod>;
|
||||
using ObjectMethodPair = std::pair<QPointer<QObject>, QMetaMethod>;
|
||||
|
||||
QMutex _packetListenerLock;
|
||||
QHash<PacketType::Value, ObjectMethodPair> _packetListenerMap;
|
||||
|
|
|
@ -14,11 +14,9 @@
|
|||
|
||||
#include <QtCore/QSharedPointer>
|
||||
|
||||
#include "PacketListener.h"
|
||||
|
||||
#include "Assignment.h"
|
||||
|
||||
class ThreadedAssignment : public Assignment, public PacketListener {
|
||||
class ThreadedAssignment : public Assignment {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ThreadedAssignment(NLPacket& packet);
|
||||
|
|
Loading…
Reference in a new issue