1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2024-10-27 20:44:10 +00:00

client now connects (but still does not communicate)

This commit is contained in:
Falk Werner 2019-02-23 16:20:30 +01:00
parent 9f468f600e
commit 03b8ee473a
2 changed files with 39 additions and 4 deletions

View File

@ -8,7 +8,9 @@
#include "wsfsp/provider.h"
#include "wsfsp/client_protocol_intern.h"
#include "wsfsp/url.h"
#define WSFSP_PROTOCOL ("fs")
#define WSFSP_DISABLE_LWS_LOG 0
#define WSFSP_CLIENT_PROTOCOL_COUNT 2
#define WSFSP_CLIENT_TIMEOUT (1 * 1000)
@ -21,6 +23,7 @@ struct wsfsp_client
struct lws_context_creation_info info;
struct lws_protocols protocols[WSFSP_CLIENT_PROTOCOL_COUNT];
struct lws_context * context;
struct lws * wsi;
};
@ -64,10 +67,26 @@ void wsfsp_client_connect(
struct wsfsp_client * client,
char const * url)
{
(void) client;
(void) url;
struct wsfsp_url url_data;
bool const success = wsfsp_url_init(&url_data, url);
if (success)
{
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;
// ToDo: implement me
lws_client_connect_via_info(&info);
wsfsp_url_cleanup(&url_data);
}
}
void wsfsp_client_disconnect(

View File

@ -10,11 +10,27 @@
static int wsfsp_client_protocol_callback(
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(in),
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;
}