MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / start

Method start

src/tools/debugadapter/dapsession.cpp:106–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106bool DapSession::start()
107{
108 auto onClientConnected = [this](const std::shared_ptr<ReaderWriter> &socket) {
109 QMetaObject::invokeMethod(this, "initialize", Qt::BlockingQueuedConnection, Q_ARG(std::shared_ptr<dap::ReaderWriter>, socket));
110 };
111
112 auto onError = [](const char *errMessage) {
113 Log(errMessage)
114 };
115
116 // Create the network server
117 d->server = dap::net::Server::create();
118
119 auto checkPortFree = [](int port) {
120 QProcess process;
121 QString cmd = QString("fuser %1/tcp").arg(port);
122 process.start(cmd);
123 process.waitForFinished();
124 QString ret = process.readAll();
125 if (ret.isEmpty())
126 return true;
127 return false;
128 };
129
130 bool ret = false;
131 int port = kPort;
132 while (port - kPort < maxTryNum) {
133 if (checkPortFree(port)) {
134 // Start listening on kPort.
135 // onClientConnected will be called when a client wants to connect.
136 // onError will be called on any connection errors.
137 ret = d->server->start(port, onClientConnected, onError);
138 if (ret) {
139 d->serverInfo.setPort(port);
140 break;
141 }
142 }
143 port++;
144 }
145 return ret;
146}
147
148void DapSession::stop()
149{

Callers 12

executeMethod · 0.45
mainFunction · 0.45
packageInstallPathFunction · 0.45
initializeMethod · 0.45
initializeMethod · 0.45
checkJSServerMethod · 0.45
checkShasumMethod · 0.45
getRemoteFileMethod · 0.45
packageInstallPathFunction · 0.45
selectLspServerFunction · 0.45
mainFunction · 0.45
startAllMethod · 0.45

Calls 5

createFunction · 0.85
readAllMethod · 0.80
setPortMethod · 0.80
QStringClass · 0.50
isEmptyMethod · 0.45

Tested by

no test coverage detected