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>
* Copyright (C) 2015, 2016 "IoT.bzh"
* Author "Fulup Ar Foll"
* Author José Bollo <jose.bollo@iot.bzh>
* Copyright (C) 2015, 2016 "IoT.bzh"
* Author "Fulup Ar Foll"
* Author José Bollo <jose.bollo@iot.bzh>
#include <systemd/sd-event.h>
#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"
#include "afb-wsj1.h"
#include "afb-ws-client.h"
if (ac == 2) {
/* get requests from stdin */
fcntl(0, F_SETFL, O_NONBLOCK);
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;
} else {
/* the request is defined by the arguments */
exonrep = 1;
/* loop until end */
for(;;)
/* loop until end */
for(;;)
- sd_event_run(afb_common_get_event_loop(), 30000000);
+ sd_event_run(afb_ws_client_get_event_loop(), 30000000);
#include <fcntl.h>
#include "afb-wsj1.h"
#include <fcntl.h>
#include "afb-wsj1.h"
/**************** WebSocket handshake ****************************/
/**************** WebSocket handshake ****************************/
/* 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)
{
/* 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"
"GET %s HTTP/1.1\r\n"
"Host: %s\r\n"
"Upgrade: websocket\r\n"
errno = EINVAL;
error:
return -1;
errno = EINVAL;
error:
return -1;
+/*
+ *
+ * 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();
+}
+
* 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);
* 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();
+
{
global:
afb_ws_client_connect_wsj1;
{
global:
afb_ws_client_connect_wsj1;
+ afb_ws_client_get_event_loop;
afb_wsj1_*;
afb_common_*;
local:
afb_wsj1_*;
afb_common_*;
local: