MCPcopy Create free account
hub / github.com/Snapchat/Valdi / connect

Method connect

valdi/src/valdi/runtime/Debugger/TCPClient.cpp:50–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48 }
49
50 void connect(const std::string& address, int32_t port, const Shared<ITCPClientListener>& listener) {
51 auto strongSelf = strongRef(this);
52 auto connection = makeShared<TCPConnectionImpl>(_ioService);
53 connection->getSocket().async_connect(
54 boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(address), static_cast<uint16_t>(port)),
55 [strongSelf, connection, listener](const boost::system::error_code& errorCode) {
56 if (errorCode.failed()) {
57 strongSelf->stopServices();
58 listener->onDisconnected(errorFromBoostError(errorCode));
59 } else {
60 {
61 std::lock_guard<Mutex> lock(strongSelf->_mutex);
62 strongSelf->_connection = connection;
63 }
64 connection->setDisconnectListener(
65 makeShared<TCPClientDisconnectListenerImpl>(strongSelf, listener).toShared());
66 connection->onReady();
67 listener->onConnected(connection);
68 }
69 });
70
71 auto result = startServices();
72 if (!result) {
73 listener->onDisconnected(result.error());
74 return;
75 }
76 }
77
78 void stopServices() {
79 _started = false;

Callers

nothing calls this directly

Calls 10

strongRefFunction · 0.85
errorFromBoostErrorFunction · 0.85
failedMethod · 0.80
stopServicesMethod · 0.80
toSharedMethod · 0.80
onReadyMethod · 0.80
errorMethod · 0.65
onDisconnectedMethod · 0.45
setDisconnectListenerMethod · 0.45
onConnectedMethod · 0.45

Tested by

no test coverage detected