client now connects (but still does not communicate)

pull/10/head
Falk Werner 6 years ago
parent 9f468f600e
commit 03b8ee473a

@ -8,7 +8,9 @@
#include "wsfsp/provider.h" #include "wsfsp/provider.h"
#include "wsfsp/client_protocol_intern.h" #include "wsfsp/client_protocol_intern.h"
#include "wsfsp/url.h"
#define WSFSP_PROTOCOL ("fs")
#define WSFSP_DISABLE_LWS_LOG 0 #define WSFSP_DISABLE_LWS_LOG 0
#define WSFSP_CLIENT_PROTOCOL_COUNT 2 #define WSFSP_CLIENT_PROTOCOL_COUNT 2
#define WSFSP_CLIENT_TIMEOUT (1 * 1000) #define WSFSP_CLIENT_TIMEOUT (1 * 1000)
@ -21,6 +23,7 @@ struct wsfsp_client
struct lws_context_creation_info info; struct lws_context_creation_info info;
struct lws_protocols protocols[WSFSP_CLIENT_PROTOCOL_COUNT]; struct lws_protocols protocols[WSFSP_CLIENT_PROTOCOL_COUNT];
struct lws_context * context; struct lws_context * context;
struct lws * wsi;
}; };
@ -64,10 +67,26 @@ void wsfsp_client_connect(
struct wsfsp_client * client, struct wsfsp_client * client,
char const * url) char const * url)
{ {
(void) client; struct wsfsp_url url_data;
(void) url; bool const success = wsfsp_url_init(&url_data, url);
if (success)
// ToDo: implement me {
struct lws_client_connect_info info;
memset(&info, 0, sizeof(struct lws_client_connect_info));
info.context = client->context;
info.port = url_data.port;
info.address = url_data.host;
info.path = url_data.path;
info.host = info.address;
info.origin = info.address;
info.ssl_connection = (url_data.use_tls) ? LCCSCF_USE_SSL : 0;
info.protocol = WSFSP_PROTOCOL;
info.pwsi = &client->wsi;
lws_client_connect_via_info(&info);
wsfsp_url_cleanup(&url_data);
}
} }
void wsfsp_client_disconnect( void wsfsp_client_disconnect(

@ -10,11 +10,27 @@
static int wsfsp_client_protocol_callback( static int wsfsp_client_protocol_callback(
struct lws * WSFS_UNUSED_PARAM(wsi), struct lws * WSFS_UNUSED_PARAM(wsi),
enum lws_callback_reasons WSFS_UNUSED_PARAM(reason), enum lws_callback_reasons reason,
void * WSFS_UNUSED_PARAM(user), void * WSFS_UNUSED_PARAM(user),
void * WSFS_UNUSED_PARAM(in), void * WSFS_UNUSED_PARAM(in),
size_t WSFS_UNUSED_PARAM(len)) size_t WSFS_UNUSED_PARAM(len))
{ {
switch (reason)
{
case LWS_CALLBACK_CLIENT_ESTABLISHED:
puts("established");
break;
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
puts("error: client could not connect");
break;
case LWS_CALLBACK_CLIENT_CLOSED:
puts("client closed");
break;
default:
break;
}
return 0; return 0;
} }

Loading…
Cancel
Save