mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 05:44:50 +02:00
Update OctreePacketProcessor to use packet callbacks
This commit is contained in:
parent
1b5d526444
commit
3b7ad982a4
2 changed files with 55 additions and 9 deletions
|
@ -16,6 +16,44 @@
|
||||||
#include "OctreePacketProcessor.h"
|
#include "OctreePacketProcessor.h"
|
||||||
#include "SceneScriptingInterface.h"
|
#include "SceneScriptingInterface.h"
|
||||||
|
|
||||||
|
OctreePacketProcessor::OctreePacketProcessor() {
|
||||||
|
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
|
||||||
|
packetReceiver.registerPacketListener(PacketType::OctreeStats, this, "handleEntityDataPacket");
|
||||||
|
packetReceiver.registerPacketListener(PacketType::EntityData, this, "handleEntityDataPacket");
|
||||||
|
packetReceiver.registerPacketListener(PacketType::EntityErase, this, "handleEntityErasePacket");
|
||||||
|
packetReceiver.registerPacketListener(PacketType::OctreeStats, this, "handleOctreeStatsPacket");
|
||||||
|
packetReceiver.registerPacketListener(PacketType::EnvironmentData, this, "handleEnvironmentDataPacket");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO implement packet processing in PacketType-specific methods
|
||||||
|
void OctreePacketProcessor::handleEntityDataPacket(std::unique_ptr<NLPacket> packet, HifiSockAddr senderSockAddr) {
|
||||||
|
SharedNodePointer sendingNode = DependencyManager::get<NodeList>()->nodeWithUUID(packet->getSourceID());
|
||||||
|
if (sendingNode) {
|
||||||
|
processPacket(sendingNode, QByteArray::fromRawData(packet->getData(), packet->getSizeWithHeader()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OctreePacketProcessor::handleEntityErasePacket(std::unique_ptr<NLPacket> packet, HifiSockAddr senderSockAddr) {
|
||||||
|
SharedNodePointer sendingNode = DependencyManager::get<NodeList>()->nodeWithUUID(packet->getSourceID());
|
||||||
|
if (sendingNode) {
|
||||||
|
processPacket(sendingNode, QByteArray::fromRawData(packet->getData(), packet->getSizeWithHeader()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OctreePacketProcessor::handleOctreeStatsPacket(std::unique_ptr<NLPacket> packet, HifiSockAddr senderSockAddr) {
|
||||||
|
SharedNodePointer sendingNode = DependencyManager::get<NodeList>()->nodeWithUUID(packet->getSourceID());
|
||||||
|
if (sendingNode) {
|
||||||
|
processPacket(sendingNode, QByteArray::fromRawData(packet->getData(), packet->getSizeWithHeader()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OctreePacketProcessor::handleEnvironmentDataPacket(std::unique_ptr<NLPacket> packet, HifiSockAddr senderSockAddr) {
|
||||||
|
SharedNodePointer sendingNode = DependencyManager::get<NodeList>()->nodeWithUUID(packet->getSourceID());
|
||||||
|
if (sendingNode) {
|
||||||
|
processPacket(sendingNode, QByteArray::fromRawData(packet->getData(), packet->getSizeWithHeader()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OctreePacketProcessor::processPacket(const SharedNodePointer& sendingNode, const QByteArray& packet) {
|
void OctreePacketProcessor::processPacket(const SharedNodePointer& sendingNode, const QByteArray& packet) {
|
||||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
"OctreePacketProcessor::processPacket()");
|
"OctreePacketProcessor::processPacket()");
|
||||||
|
|
|
@ -16,13 +16,21 @@
|
||||||
|
|
||||||
/// Handles processing of incoming voxel packets for the interface application. As with other ReceivedPacketProcessor classes
|
/// 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()
|
/// the user is responsible for reading inbound packets and adding them to the processing queue by calling queueReceivedPacket()
|
||||||
class OctreePacketProcessor : public ReceivedPacketProcessor {
|
class OctreePacketProcessor : public GenericThread {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
OctreePacketProcessor();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void packetVersionMismatch();
|
void packetVersionMismatch();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void processPacket(const SharedNodePointer& sendingNode, const QByteArray& packet);
|
virtual void processPacket(const SharedNodePointer& sendingNode, const QByteArray& packet);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void handleEntityDataPacket(std::unique_ptr<NLPacket> packet, HifiSockAddr senderSockAddr);
|
||||||
|
void handleEntityErasePacket(std::unique_ptr<NLPacket> packet, HifiSockAddr senderSockAddr);
|
||||||
|
void handleOctreeStatsPacket(std::unique_ptr<NLPacket> packet, HifiSockAddr senderSockAddr);
|
||||||
|
void handleEnvironmentDataPacket(std::unique_ptr<NLPacket> packet, HifiSockAddr senderSockAddr);
|
||||||
};
|
};
|
||||||
#endif // hifi_OctreePacketProcessor_h
|
#endif // hifi_OctreePacketProcessor_h
|
||||||
|
|
Loading…
Reference in a new issue