diff options
Diffstat (limited to 'AFBClient.cpp')
-rw-r--r-- | AFBClient.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/AFBClient.cpp b/AFBClient.cpp index 497b746..e47e23f 100644 --- a/AFBClient.cpp +++ b/AFBClient.cpp @@ -110,9 +110,8 @@ void onHangup(void *closure, afb_wsj1 *wsj1) { TRACE(); UNUSED(closure); UNUSED(wsj1); - printf("ON-HANGUP\n"); - fflush(stdout); - exit(0); + fputs("Hangup, the WindowManager vanished\n", stderr); + exit(1); } constexpr struct afb_wsj1_itf itf = { @@ -220,27 +219,27 @@ int AFBClient::Impl::init(int port, char const *token) { } if ((token == nullptr) || strlen(token) > token_maxlen) { - fprintf(stderr, "Token is invalid\n"); + fputs("Token is invalid\n", stderr); rc = -EINVAL; goto fail; } for (char const *p = token; *p != 0; p++) { if (isalnum(*p) == 0) { - fprintf(stderr, "Token is invalid\n"); + fputs("Token is invalid\n", stderr); rc = -EINVAL; goto fail; } } if (port < 1 && port > 0xffff) { - fprintf(stderr, "Port is invalid\n"); + fputs("Port is invalid\n", stderr); rc = -EINVAL; goto fail; } /* get the default event loop */ - rc = sd_event_default(&loop); + rc = sd_event_default(&this->loop); if (rc < 0) { fprintf(stderr, "Connection to default event loop failed: %s\n", strerror(-rc)); @@ -250,9 +249,9 @@ int AFBClient::Impl::init(int port, char const *token) { asprintf(&uribuf, "ws://localhost:%d/api?token=%s", port, token); /* connect the websocket wsj1 to the uri given by the first argument */ - wsj1 = afb_ws_client_connect_wsj1( - loop, uribuf, const_cast<struct afb_wsj1_itf *>(&itf), this); - if (wsj1 == nullptr) { + this->wsj1 = afb_ws_client_connect_wsj1( + this->loop, uribuf, const_cast<struct afb_wsj1_itf *>(&itf), this); + if (this->wsj1 == nullptr) { sd_event_unref(this->loop); this->loop = nullptr; fprintf(stderr, "Connection to %s failed: %m\n", uribuf); @@ -268,14 +267,15 @@ fail: int AFBClient::Impl::dispatch() { std::lock_guard<std::recursive_mutex> guard(dispatch_mutex); - return sd_event_run(loop, 1); + return sd_event_run(this->loop, 1); +} } int AFBClient::Impl::requestSurface(const char *label) { TRACE(); if (this->labels.find(label) != this->labels.end()) { - fprintf(stderr, "Surface label already known!\n"); + fputs("Surface label already known!\n", stderr); return -EINVAL; } |