afb-client-demo/afb-ws: remove dependency on afb-common.*
authorStephane Desneux <stephane.desneux@iot.bzh>
Tue, 12 Jul 2016 14:14:51 +0000 (16:14 +0200)
committerStephane Desneux <stephane.desneux@iot.bzh>
Tue, 12 Jul 2016 14:35:23 +0000 (14:35 +0000)
afb-common.* files are not public and so not distributed
in any development package. This makes difficult to create
a client with sources out-of-tree.

Change-Id: Ib2edd48f864f55821ab590442efdf6d1e2fdcd58
Signed-off-by: Stephane Desneux <stephane.desneux@iot.bzh>
src/afb-client-demo.c
src/afb-ws-client.c
src/afb-ws-client.h
src/export-afbwsc.map

index 6f494a6..1ead5f7 100644 (file)
@@ -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;
 }
 
index e9c1a90..de44a39 100644 (file)
@@ -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();
+}
+
 
index f2aee7d..cac4c78 100644 (file)
@@ -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();
+
index c775a16..ac7dea5 100644 (file)
@@ -1,6 +1,7 @@
 {
 global:
        afb_ws_client_connect_wsj1;
+       afb_ws_client_get_event_loop;
        afb_wsj1_*;
        afb_common_*;
 local: