MCPcopy Create free account
hub / github.com/KDAB/GammaRay / Server

Method Server

core/remote/server.cpp:39–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37using namespace std;
38
39Server::Server(QObject *parent)
40 : Endpoint(parent)
41 , m_serverDevice(nullptr)
42 , m_nextAddress(endpointAddress())
43 , m_broadcastTimer(new QTimer(this))
44 , m_signalMapper(new MultiSignalMapper(this))
45{
46 Message::resetNegotiatedDataVersion();
47
48 if (!ProbeSettings::value(QStringLiteral("RemoteAccessEnabled"), true).toBool())
49 return;
50
51 const auto serverAddress = serverAddress_impl();
52 m_serverDevice = ServerDevice::create(serverAddress, this);
53 if (!m_serverDevice)
54 return;
55
56 connect(m_serverDevice, &ServerDevice::newConnection, this, &Server::newConnection);
57 connect(m_serverDevice, &ServerDevice::externalAddressChanged, this, &Server::externalAddressChanged);
58
59 m_broadcastTimer->setInterval(5 * 1000);
60 m_broadcastTimer->setSingleShot(false);
61 if (serverAddress.scheme() == QLatin1String("tcp")) {
62 m_broadcastTimer->start();
63 }
64 connect(m_broadcastTimer, &QTimer::timeout, this, &Server::broadcast);
65 connect(this, &Server::disconnected, m_broadcastTimer, [this] { m_broadcastTimer->start(); });
66
67 connect(m_signalMapper, &MultiSignalMapper::signalEmitted,
68 this, &Server::forwardSignal);
69
70 Endpoint::addObjectNameAddressMapping(QStringLiteral(
71 "com.kdab.GammaRay.PropertySyncer"),
72 ++m_nextAddress);
73 m_propertySyncer->setAddress(m_nextAddress);
74 Endpoint::registerObject(QStringLiteral("com.kdab.GammaRay.PropertySyncer"), m_propertySyncer);
75 registerMessageHandler(m_nextAddress, m_propertySyncer, "handleMessage");
76}
77
78Server::~Server() = default;
79

Callers

nothing calls this directly

Calls 3

registerObjectFunction · 0.85
setAddressMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected