Skip to content

Commit

Permalink
Remove ui_ready from uWs server is_connected as that caused blocking …
Browse files Browse the repository at this point in the history
…Apitests
  • Loading branch information
mmertama committed Mar 24, 2024
1 parent f65953d commit 05ef1eb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gempyrelib/js/gempyre.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ socket.onopen = function(event) {
// one guess is that in API tests there no events coming
setTimeout(function() {
socket.send(JSON.stringify({'type': 'event',
'element': '', 'event': 'ui_ready'}));
'element': '', 'event': 'ui_ready', 'properties':{}}));
}, 100);

socket.send(JSON.stringify({'type': 'ui_ready'}));
Expand Down
8 changes: 8 additions & 0 deletions gempyrelib/src/gempyre_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,14 @@ std::function<void(int)> GempyreInternal::makeCaller(const std::function<void (U
void GempyreInternal::consume_events() {
while(has_events() && *this == State::RUNNING) {
const auto it = m_eventqueue.take();
if(it.element.empty()) {
GempyreUtils::log(GempyreUtils::LogLevel::Debug,
"Root got event:", it.handler,
"has open:", has_open(),
"State:", state_str(),
"Connected", is_connected());
continue;
}
const auto element = m_elements.find(it.element);
if(element != m_elements.end()) {
const auto handlerName = it.handler;
Expand Down
2 changes: 1 addition & 1 deletion gempyrelib/src/uwebsockets/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ bool Uws_Server::retryStart() {
}

bool Uws_Server::isConnected() const {
return !m_broadcaster->empty() && m_uiready;
return !m_broadcaster->empty() /*&& m_uiready*/; // why was this -
}

bool Uws_Server::beginBatch() {
Expand Down
2 changes: 1 addition & 1 deletion test/mock_browser/ws_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bool App::on_status(websocket::Status status) {
const auto ready = Json({{"type", "ui_ready"}}).dump();
send_message(ready.c_str());
std::this_thread::sleep_for(10ms);
const auto event = Json({{"type", "event"}, {"element", ""}, {"event", "ui_ready"}}).dump();
const auto event = Json({{"type", "event"}, {"element", ""}, {"event", "ui_ready"}, {"properties", Json::object()}}).dump();
send_message(event.c_str());
return true;
}
Expand Down

0 comments on commit 05ef1eb

Please sign in to comment.