stream << magic;
// here goes the list of protocols we support, in order of preference
- stream << ((quint32)Protocol::LegacyProtocol | 0x80000000); // end list
+ PeerFactory::ProtoList protos = PeerFactory::supportedProtocols();
+ for (int i = 0; i < protos.count(); ++i) {
+ quint32 reply = protos[i].first;
+ reply |= protos[i].second<<8;
+ if (i == protos.count() - 1)
+ reply |= 0x80000000; // end list
+ stream << reply;
+ }
socket()->flush(); // make sure the probing data is sent immediately
return;
#include "protocols/legacy/legacypeer.h"
+
+PeerFactory::ProtoList PeerFactory::supportedProtocols()
+{
+ ProtoList result;
+ result.append(ProtoDescriptor(Protocol::LegacyProtocol, 0));
+ return result;
+}
+
+
RemotePeer *PeerFactory::createPeer(const ProtoDescriptor &protocol, AuthHandler *authHandler, QTcpSocket *socket, QObject *parent)
{
return createPeer(ProtoList() << protocol, authHandler, socket, parent);
typedef QPair<Protocol::Type, quint16> ProtoDescriptor;
typedef QVector<ProtoDescriptor> ProtoList;
+ static ProtoList supportedProtocols();
+
static RemotePeer *createPeer(const ProtoDescriptor &protocol, AuthHandler *authHandler, QTcpSocket *socket, QObject *parent = 0);
static RemotePeer *createPeer(const ProtoList &protocols, AuthHandler *authHandler, QTcpSocket *socket, QObject *parent = 0);