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 = {
}
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));
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);
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;
}