| 162 | } |
| 163 | |
| 164 | JSON::Value<wchar_t> SendRequest(const char* method, const std::wstring& params) |
| 165 | { |
| 166 | concurrency::task_completion_event<JSON::Value<wchar_t>> response; |
| 167 | int id = idCounter += 1; |
| 168 | if (!Connected()) return {}; |
| 169 | mapQueue->try_emplace(id, response); |
| 170 | QMetaObject::invokeMethod(&webSocket, std::bind(&QWebSocket::sendTextMessage, &webSocket, S(FormatString(LR"({"id":%d,"method":"%S","params":%s})", id, method, params)))); |
| 171 | try { if (auto result = create_task(response).get()[L"result"]) return result; } catch (...) {} |
| 172 | return {}; |
| 173 | } |
| 174 | } |