aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/afb-client-demo.c7
-rw-r--r--src/afb-ws-client.c16
-rw-r--r--src/afb-ws-client.h4
-rw-r--r--src/export-afbwsc.map1
4 files changed, 22 insertions, 6 deletions
diff --git a/src/afb-client-demo.c b/src/afb-client-demo.c
index 6f494a6a..1ead5f74 100644
--- a/src/afb-client-demo.c
+++ b/src/afb-client-demo.c
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2015, 2016 "IoT.bzh"
* Author "Fulup Ar Foll"
* Author José Bollo <jose.bollo@iot.bzh>
@@ -30,7 +30,6 @@
#include <systemd/sd-event.h>
-#include "afb-common.h" /* TODO: remove dependency to afb-common.h */
#include "afb-wsj1.h"
#include "afb-ws-client.h"
@@ -85,7 +84,7 @@ int main(int ac, char **av, char **env)
if (ac == 2) {
/* get requests from stdin */
fcntl(0, F_SETFL, O_NONBLOCK);
- sd_event_add_io(afb_common_get_event_loop(), &evsrc, 0, EPOLLIN, io_event_callback, NULL);
+ sd_event_add_io(afb_ws_client_get_event_loop(), &evsrc, 0, EPOLLIN, io_event_callback, NULL);
} else {
/* the request is defined by the arguments */
exonrep = 1;
@@ -94,7 +93,7 @@ int main(int ac, char **av, char **env)
/* loop until end */
for(;;)
- sd_event_run(afb_common_get_event_loop(), 30000000);
+ sd_event_run(afb_ws_client_get_event_loop(), 30000000);
return 0;
}
diff --git a/src/afb-ws-client.c b/src/afb-ws-client.c
index e9c1a906..de44a398 100644
--- a/src/afb-ws-client.c
+++ b/src/afb-ws-client.c
@@ -29,6 +29,7 @@
#include <fcntl.h>
#include "afb-wsj1.h"
+#include "afb-common.h"
/**************** WebSocket handshake ****************************/
@@ -111,7 +112,7 @@ static char *strjoin(int count, const char **strings, const char *separ)
/* creates the http message for the request */
static int make_request(char **request, const char *path, const char *host, const char *key, const char *protocols)
{
- int rc = asprintf(request,
+ int rc = asprintf(request,
"GET %s HTTP/1.1\r\n"
"Host: %s\r\n"
"Upgrade: websocket\r\n"
@@ -314,7 +315,7 @@ invalid:
errno = EINVAL;
error:
return -1;
-
+
}
@@ -406,4 +407,15 @@ static char *makequery(const char *path, const char *uuid, const char *token)
}
#endif
+/*
+ *
+ * Returns the internal event loop coming from afb-common
+ *
+ * Returns the handle to the event loop
+ */
+struct sd_event *afb_ws_client_get_event_loop()
+{
+ return afb_common_get_event_loop();
+}
+
diff --git a/src/afb-ws-client.h b/src/afb-ws-client.h
index f2aee7d0..cac4c782 100644
--- a/src/afb-ws-client.h
+++ b/src/afb-ws-client.h
@@ -27,3 +27,7 @@ struct afb_wsj1_itf;
* Returns NULL in case of failure with errno set appriately.
*/
extern struct afb_wsj1 *afb_ws_client_connect_wsj1(const char *uri, struct afb_wsj1_itf *itf, void *closure);
+
+struct sd_event;
+extern struct sd_event *afb_ws_client_get_event_loop();
+
diff --git a/src/export-afbwsc.map b/src/export-afbwsc.map
index c775a16f..ac7dea58 100644
--- a/src/export-afbwsc.map
+++ b/src/export-afbwsc.map
@@ -1,6 +1,7 @@
{
global:
afb_ws_client_connect_wsj1;
+ afb_ws_client_get_event_loop;
afb_wsj1_*;
afb_common_*;
local: