diff --git a/client/tp-player/main.cpp b/client/tp-player/main.cpp index 82e2531..50a6f66 100644 --- a/client/tp-player/main.cpp +++ b/client/tp-player/main.cpp @@ -45,9 +45,9 @@ void show_usage(QCommandLineParser& parser) { int main(int argc, char *argv[]) { -//#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) -// QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); -//#endif +#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif QApplication a(argc, argv); diff --git a/client/tp_assist_win/tp_assist.cpp b/client/tp_assist_win/tp_assist.cpp index 92381ab..f234a86 100644 --- a/client/tp_assist_win/tp_assist.cpp +++ b/client/tp_assist_win/tp_assist.cpp @@ -243,7 +243,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (!g_url_protocol.empty()) { - TsWsClient::url_scheme_handler(g_url_protocol); + g_ws_client.url_scheme_handler(g_url_protocol); } return DefWindowProc(hWnd, message, wParam, lParam); @@ -255,7 +255,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } break; case WM_DESTROY: - TsWsClient::stop_all_client(); + g_ws_client.stop_all_client(); SendMessage(g_hDlgMain, WMU_DLG_MAIN_EXIT, NULL, NULL); PostQuitMessage(0); break; @@ -264,7 +264,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) COPYDATASTRUCT* data = (COPYDATASTRUCT*)lParam; ex_astr url_protocol((char*)data->lpData); // MessageBoxA(hWnd, url_protocol.c_str(), "url-protocol", MB_OK); - TsWsClient::url_scheme_handler(url_protocol); + g_ws_client.url_scheme_handler(url_protocol); break; } default: diff --git a/client/tp_assist_win/ts_ws_client.cpp b/client/tp_assist_win/ts_ws_client.cpp index 4a99e78..079eb8f 100644 --- a/client/tp_assist_win/ts_ws_client.cpp +++ b/client/tp_assist_win/ts_ws_client.cpp @@ -100,7 +100,6 @@ password 51:b:%s\n\ //#endif TsWsClient g_ws_client; -TsWsClient g_wss_client; void* g_app = NULL; @@ -137,7 +136,6 @@ void TsWsClient::init_app(void* app) void TsWsClient::stop_all_client() { g_ws_client.stop(); - g_wss_client.stop(); } // ============================================================================ @@ -174,15 +172,14 @@ void TsWsClient::url_scheme_handler(const std::string& url) return; } - // now we support 'register' method only. method.assign(url, pos_protocol + 3, pos_method - pos_protocol - 3); - if (method[method.length() - 1] == '/') - method.erase(method.length() - 1, 1); - if (method != "register") + if (method.empty()) { - EXLOGE("[url-schema] unknown method: %s\n", method.c_str()); + EXLOGE("[ws] no method, what should I do now?\n"); return; } + if (method[method.length() - 1] == '/') + method.erase(method.length() - 1, 1); param.assign(url, pos_method + 7); // ?param= if (param.empty()) @@ -223,8 +220,23 @@ void TsWsClient::url_scheme_handler(const std::string& url) return; } - // now we support 'register' method only. - _process_register(param, js_root); + if (method == "register") + { + _process_register(param, js_root); + } + else if (method == "run") + { + _process_run(param, js_root); + } + else if (method == "replay_rdp") + { + _process_replay_rdp(param, js_root); + } + else + { + EXLOGE("[ws] unknown method: %s\n", method.c_str()); + return; + } } // static @@ -244,14 +256,14 @@ void TsWsClient::_process_register(const std::string& param, Json::Value& js_roo std::string session_id = js_root["session_id"].asCString(); std::string protocol; - protocol.assign(ws_url, 0, 3); - if (protocol == "ws:") + protocol.assign(ws_url, 0, 5); + if (protocol == "ws://") { g_ws_client._register(false, ws_url, assist_id, session_id); } - else if (protocol == "wss") + else if (protocol == "wss:/") { - g_wss_client._register(true, ws_url, assist_id, session_id); + g_ws_client._register(true, ws_url, assist_id, session_id); } else { @@ -260,6 +272,32 @@ void TsWsClient::_process_register(const std::string& param, Json::Value& js_roo } } +void TsWsClient::_process_run(const std::string& param, Json::Value& js_root) +{ + // wrapper for _rpc_func_run_client(). + + Json::Value js_param; + js_param["method"] = "run"; + js_param["param"] = js_root; + + AssistMessage msg_req; + std::string buf; + _rpc_func_run_client(buf, msg_req, js_param); +} + +void TsWsClient::_process_replay_rdp(const std::string& param, Json::Value& js_root) +{ + // wrapper for _rpc_func_replay_rdp(). + + Json::Value js_param; + js_param["method"] = "replay_rdp"; + js_param["param"] = js_root; + + AssistMessage msg_req; + std::string buf; + _rpc_func_replay_rdp(buf, msg_req, js_param); +} + // ============================================================================ diff --git a/client/tp_assist_win/ts_ws_client.h b/client/tp_assist_win/ts_ws_client.h index 1ac1d8d..428ad0f 100644 --- a/client/tp_assist_win/ts_ws_client.h +++ b/client/tp_assist_win/ts_ws_client.h @@ -33,10 +33,10 @@ public: ~TsWsClient(); - static void init_app(void* app); - static void stop_all_client(); + void init_app(void* app); + void stop_all_client(); - static void url_scheme_handler(const std::string& url); + void url_scheme_handler(const std::string& url); protected: void _thread_loop(void); @@ -66,7 +66,9 @@ private: static void _mg_event_handler(struct mg_connection* nc, int ev, void* ev_data); - static void _process_register(const std::string& param, Json::Value& js_root); + void _process_register(const std::string& param, Json::Value& js_root); + void _process_run(const std::string& param, Json::Value& js_root); + void _process_replay_rdp(const std::string& param, Json::Value& js_root); private: struct mg_mgr m_mg_mgr; @@ -74,4 +76,7 @@ private: uint32_t m_assist_id; }; +extern TsWsClient g_ws_client; + + #endif // __TS_WS_CLIENT_H__