mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-06 12:23:09 +02:00
have the OctreeEditPacketSender emit a signal when payment is required
This commit is contained in:
parent
04effabe48
commit
eba92eb517
2 changed files with 21 additions and 4 deletions
|
@ -26,7 +26,10 @@ OctreeEditPacketSender::OctreeEditPacketSender() :
|
||||||
_maxPendingMessages(DEFAULT_MAX_PENDING_MESSAGES),
|
_maxPendingMessages(DEFAULT_MAX_PENDING_MESSAGES),
|
||||||
_releaseQueuedMessagesPending(false),
|
_releaseQueuedMessagesPending(false),
|
||||||
_serverJurisdictions(NULL),
|
_serverJurisdictions(NULL),
|
||||||
_maxPacketSize(MAX_PACKET_SIZE) {
|
_maxPacketSize(MAX_PACKET_SIZE),
|
||||||
|
_destinationWalletUUID()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OctreeEditPacketSender::~OctreeEditPacketSender() {
|
OctreeEditPacketSender::~OctreeEditPacketSender() {
|
||||||
|
@ -99,6 +102,12 @@ void OctreeEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, unsigned c
|
||||||
QByteArray packet(reinterpret_cast<const char*>(buffer), length);
|
QByteArray packet(reinterpret_cast<const char*>(buffer), length);
|
||||||
queuePacketForSending(node, packet);
|
queuePacketForSending(node, packet);
|
||||||
|
|
||||||
|
if (hasDestinationWalletUUID() && satoshiCost > 0) {
|
||||||
|
// if we have a destination wallet UUID and a cost associated with this packet, signal that it
|
||||||
|
// needs to be sent
|
||||||
|
emit octreePaymentRequired(satoshiCost, nodeUUID, _destinationWalletUUID);
|
||||||
|
}
|
||||||
|
|
||||||
// add packet to history
|
// add packet to history
|
||||||
_sentPacketHistories[nodeUUID].packetSent(sequence, packet);
|
_sentPacketHistories[nodeUUID].packetSent(sequence, packet);
|
||||||
|
|
||||||
|
|
|
@ -83,11 +83,17 @@ public:
|
||||||
virtual char getMyNodeType() const = 0;
|
virtual char getMyNodeType() const = 0;
|
||||||
virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) { };
|
virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) { };
|
||||||
|
|
||||||
|
bool hasDestinationWalletUUID() const { return _destinationWalletUUID.isNull(); }
|
||||||
|
void setDestinationWalletUUID(const QUuid& destinationWalletUUID) { _destinationWalletUUID = destinationWalletUUID; }
|
||||||
|
const QUuid& getDestinationWalletUUID() { return _destinationWalletUUID; }
|
||||||
|
|
||||||
|
void processNackPacket(const QByteArray& packet);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void nodeKilled(SharedNodePointer node);
|
void nodeKilled(SharedNodePointer node);
|
||||||
|
|
||||||
public:
|
signals:
|
||||||
void processNackPacket(const QByteArray& packet);
|
void octreePaymentRequired(qint64 satoshiAmount, const QUuid& nodeUUID, const QUuid& destinationWalletUUID);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool _shouldSend;
|
bool _shouldSend;
|
||||||
|
@ -118,5 +124,7 @@ protected:
|
||||||
// TODO: add locks for this and _pendingEditPackets
|
// TODO: add locks for this and _pendingEditPackets
|
||||||
QHash<QUuid, SentPacketHistory> _sentPacketHistories;
|
QHash<QUuid, SentPacketHistory> _sentPacketHistories;
|
||||||
QHash<QUuid, quint16> _outgoingSequenceNumbers;
|
QHash<QUuid, quint16> _outgoingSequenceNumbers;
|
||||||
|
|
||||||
|
QUuid _destinationWalletUUID;
|
||||||
};
|
};
|
||||||
#endif // hifi_OctreeEditPacketSender_h
|
#endif // hifi_OctreeEditPacketSender_h
|
||||||
|
|
Loading…
Reference in a new issue