#include <pthread.h>
#include <json-c/json.h>
-#include <systemd/sd-event.h>
-
-#include "afb-common.h"
#include "afb-ws.h"
#include "afb-msg-json.h"
#include "afb-proto-ws.h"
-#include "verbose.h"
struct afb_proto_ws;
goto success;
}
}
- ERROR("error while sending success");
success:
return rc;
}
goto success;
}
}
- ERROR("error while sending fail");
success:
return rc;
}
}
}
}
- ERROR("error while sending subcall");
success:
return rc;
}
goto success;
}
}
- ERROR("error while subscribing event");
success:
return rc;
}
goto success;
}
}
- ERROR("error while subscribing event");
success:
return rc;
}
/* get event data from the message */
if (!readbuf_uint32(rb, &callid)) {
- ERROR("Invalid message");
return 0;
}
/* get the call */
*call = client_call_search(protows, callid);
if (*call == NULL) {
- ERROR("message not found");
return 0;
}
/*****************************************************/
-static struct afb_proto_ws *afb_proto_ws_create(int fd, const struct afb_proto_ws_server_itf *itfs, const struct afb_proto_ws_client_itf *itfc, void *closure, const struct afb_ws_itf *itf)
+static struct afb_proto_ws *afb_proto_ws_create(struct sd_event *eloop, int fd, const struct afb_proto_ws_server_itf *itfs, const struct afb_proto_ws_client_itf *itfc, void *closure, const struct afb_ws_itf *itf)
{
struct afb_proto_ws *protows;
else {
fcntl(fd, F_SETFD, FD_CLOEXEC);
fcntl(fd, F_SETFL, O_NONBLOCK);
- protows->ws = afb_ws_create(afb_common_get_event_loop(), fd, itf, protows);
+ protows->ws = afb_ws_create(eloop, fd, itf, protows);
if (protows->ws != NULL) {
protows->fd = fd;
protows->refcount = 1;
return NULL;
}
-struct afb_proto_ws *afb_proto_ws_create_client(int fd, const struct afb_proto_ws_client_itf *itf, void *closure)
+struct afb_proto_ws *afb_proto_ws_create_client(struct sd_event *eloop, int fd, const struct afb_proto_ws_client_itf *itf, void *closure)
{
- return afb_proto_ws_create(fd, NULL, itf, closure, &proto_ws_client_ws_itf);
+ return afb_proto_ws_create(eloop, fd, NULL, itf, closure, &proto_ws_client_ws_itf);
}
-struct afb_proto_ws *afb_proto_ws_create_server(int fd, const struct afb_proto_ws_server_itf *itf, void *closure)
+struct afb_proto_ws *afb_proto_ws_create_server(struct sd_event *eloop, int fd, const struct afb_proto_ws_server_itf *itf, void *closure)
{
- return afb_proto_ws_create(fd, itf, NULL, closure, &server_ws_itf);
+ return afb_proto_ws_create(eloop, fd, itf, NULL, closure, &server_ws_itf);
}
void afb_proto_ws_unref(struct afb_proto_ws *protows)