MCPcopy Create free account
hub / github.com/RGAA-Software/GoDesk / Start

Method Start

src/client/transfer/file_transfer.cpp:25–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23 }
24
25 void FileTransferChannel::Start() {
26 client_ = std::make_shared<asio2::ws_client>();
27 client_->set_connect_timeout(std::chrono::seconds(5));
28 client_->set_auto_reconnect(true);
29 client_->bind_init([&]() {
30 client_->ws_stream().binary(true);
31 client_->ws_stream().set_option(
32 websocket::stream_base::decorator([](websocket::request_type &req) {
33 req.set(http::field::authorization, "websocket-client_-authorization");
34 })
35 );
36
37 }).bind_connect([&]() {
38 if (asio2::get_last_error()) {
39 LOGE("connect failure: {}->{}", asio2::last_error_val(), asio2::last_error_msg().c_str());
40 } else {
41 LOGI("connect success.");
42 }
43 }).bind_disconnect([&]() {
44 LOGE("Disconnect!!!");
45
46 }).bind_upgrade([&]() {
47 if (asio2::get_last_error()) {
48 LOGE("update failure: {}->{}", asio2::last_error_val(), asio2::last_error_msg().c_str());
49 } else {
50 LOGI("update success.");
51 }
52 }).bind_recv([=, this](std::string_view data) {
53 this->ParseRespMessage(data);
54 });
55
56 auto host = Settings::Instance()->remote_address_;
57 auto port = Settings::Instance()->file_transfer_port_;
58 auto path = Settings::Instance()->file_transfer_path_;
59 if (!client_->async_start(host, port, path)) {
60 LOGE("connect websocket server failure : {}->{}",
61 asio2::last_error_val(), asio2::last_error_msg().c_str());
62 }
63 }
64
65 void FileTransferChannel::Exit() {
66 if (client_) {

Callers

nothing calls this directly

Calls 1

ParseRespMessageMethod · 0.95

Tested by

no test coverage detected