mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +02:00
pass ICE client ID through to domain-server for identification
This commit is contained in:
parent
15cc08da97
commit
5786d828a0
5 changed files with 23 additions and 14 deletions
|
@ -25,6 +25,7 @@ DomainHandler::DomainHandler(QObject* parent) :
|
|||
_uuid(),
|
||||
_sockAddr(HifiSockAddr(QHostAddress::Null, DEFAULT_DOMAIN_SERVER_PORT)),
|
||||
_assignmentUUID(),
|
||||
_iceClientID(),
|
||||
_iceServerSockAddr(),
|
||||
_icePeer(),
|
||||
_isConnected(false),
|
||||
|
@ -138,6 +139,9 @@ void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname,
|
|||
setUUID(id);
|
||||
_iceServerSockAddr = HifiSockAddr(iceServerHostname, ICE_SERVER_DEFAULT_PORT);
|
||||
|
||||
// refresh our ICE client UUID to something new
|
||||
_iceClientID = QUuid::createUuid();
|
||||
|
||||
qDebug() << "ICE required to connect to domain via ice server at" << iceServerHostname;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ public:
|
|||
const QUuid& getAssignmentUUID() const { return _assignmentUUID; }
|
||||
void setAssignmentUUID(const QUuid& assignmentUUID) { _assignmentUUID = assignmentUUID; }
|
||||
|
||||
const QUuid& getICEClientID() const { return _iceClientID; }
|
||||
|
||||
bool requiresICE() const { return !_iceServerSockAddr.isNull(); }
|
||||
const HifiSockAddr& getICEServerSockAddr() const { return _iceServerSockAddr; }
|
||||
const NetworkPeer& getICEPeer() const { return _icePeer; }
|
||||
|
@ -95,6 +97,7 @@ private:
|
|||
QString _hostname;
|
||||
HifiSockAddr _sockAddr;
|
||||
QUuid _assignmentUUID;
|
||||
QUuid _iceClientID;
|
||||
HifiSockAddr _iceServerSockAddr;
|
||||
NetworkPeer _icePeer;
|
||||
bool _isConnected;
|
||||
|
|
|
@ -459,8 +459,9 @@ unsigned LimitedNodeList::broadcastToNodes(const QByteArray& packet, const NodeS
|
|||
return n;
|
||||
}
|
||||
|
||||
QByteArray LimitedNodeList::constructPingPacket(PingType_t pingType, bool isVerified) {
|
||||
QByteArray pingPacket = byteArrayWithPopulatedHeader(isVerified ? PacketTypePing : PacketTypeUnverifiedPing);
|
||||
QByteArray LimitedNodeList::constructPingPacket(PingType_t pingType, bool isVerified, const QUuid& packetHeaderID) {
|
||||
QByteArray pingPacket = byteArrayWithPopulatedHeader(isVerified ? PacketTypePing : PacketTypeUnverifiedPing,
|
||||
packetHeaderID);
|
||||
|
||||
QDataStream packetStream(&pingPacket, QIODevice::Append);
|
||||
|
||||
|
@ -470,7 +471,7 @@ QByteArray LimitedNodeList::constructPingPacket(PingType_t pingType, bool isVeri
|
|||
return pingPacket;
|
||||
}
|
||||
|
||||
QByteArray LimitedNodeList::constructPingReplyPacket(const QByteArray& pingPacket) {
|
||||
QByteArray LimitedNodeList::constructPingReplyPacket(const QByteArray& pingPacket, const QUuid& packetHeaderID) {
|
||||
QDataStream pingPacketStream(pingPacket);
|
||||
pingPacketStream.skipRawData(numBytesForPacketHeader(pingPacket));
|
||||
|
||||
|
@ -483,7 +484,7 @@ QByteArray LimitedNodeList::constructPingReplyPacket(const QByteArray& pingPacke
|
|||
PacketType replyType = (packetTypeForPacket(pingPacket) == PacketTypePing)
|
||||
? PacketTypePingReply : PacketTypeUnverifiedPingReply;
|
||||
|
||||
QByteArray replyPacket = byteArrayWithPopulatedHeader(replyType);
|
||||
QByteArray replyPacket = byteArrayWithPopulatedHeader(replyType, packetHeaderID);
|
||||
QDataStream packetStream(&replyPacket, QIODevice::Append);
|
||||
|
||||
packetStream << typeFromOriginalPing << timeFromOriginalPing << usecTimestampNow();
|
||||
|
|
|
@ -112,8 +112,9 @@ public:
|
|||
void getPacketStats(float &packetsPerSecond, float &bytesPerSecond);
|
||||
void resetPacketStats();
|
||||
|
||||
QByteArray constructPingPacket(PingType_t pingType = PingType::Agnostic, bool isVerified = true);
|
||||
QByteArray constructPingReplyPacket(const QByteArray& pingPacket);
|
||||
QByteArray constructPingPacket(PingType_t pingType = PingType::Agnostic, bool isVerified = true,
|
||||
const QUuid& packetHeaderID = QUuid());
|
||||
QByteArray constructPingReplyPacket(const QByteArray& pingPacket, const QUuid& packetHeaderID = QUuid());
|
||||
|
||||
virtual void sendSTUNRequest();
|
||||
virtual bool processSTUNResponse(const QByteArray& packet);
|
||||
|
|
|
@ -167,7 +167,7 @@ void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, const QByteAr
|
|||
}
|
||||
case PacketTypeUnverifiedPing: {
|
||||
// send back a reply
|
||||
QByteArray replyPacket = constructPingReplyPacket(packet);
|
||||
QByteArray replyPacket = constructPingReplyPacket(packet, _domainHandler.getICEClientID());
|
||||
writeUnverifiedDatagram(replyPacket, senderSockAddr);
|
||||
break;
|
||||
}
|
||||
|
@ -328,20 +328,20 @@ void NodeList::sendDomainServerCheckIn() {
|
|||
}
|
||||
|
||||
void NodeList::handleICEConnectionToDomainServer() {
|
||||
static QUuid iceUUID = QUuid::createUuid();
|
||||
|
||||
if (_domainHandler.getICEPeer().isNull()) {
|
||||
LimitedNodeList::sendHeartbeatToIceServer(_domainHandler.getICEServerSockAddr(), iceUUID, _domainHandler.getUUID());
|
||||
LimitedNodeList::sendHeartbeatToIceServer(_domainHandler.getICEServerSockAddr(),
|
||||
_domainHandler.getICEClientID(),
|
||||
_domainHandler.getUUID());
|
||||
} else {
|
||||
qDebug() << "Sending ping packets to establish connectivity with domain-server with ID"
|
||||
<< uuidStringWithoutCurlyBraces(_domainHandler.getUUID());
|
||||
|
||||
// send the ping packet to the local and public sockets for this node
|
||||
QByteArray localPingPacket = constructPingPacket(PingType::Local, false);
|
||||
writeDatagram(localPingPacket, _domainHandler.getICEPeer().getLocalSocket(), iceUUID);
|
||||
QByteArray localPingPacket = constructPingPacket(PingType::Local, false, _domainHandler.getICEClientID());
|
||||
writeUnverifiedDatagram(localPingPacket, _domainHandler.getICEPeer().getLocalSocket());
|
||||
|
||||
QByteArray publicPingPacket = constructPingPacket(PingType::Public, false);
|
||||
writeDatagram(publicPingPacket, _domainHandler.getICEPeer().getPublicSocket(), iceUUID);
|
||||
QByteArray publicPingPacket = constructPingPacket(PingType::Public, false, _domainHandler.getICEClientID());
|
||||
writeUnverifiedDatagram(publicPingPacket, _domainHandler.getICEPeer().getPublicSocket());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue