|
@@ -218,19 +218,22 @@ void IZ_WSClientAttemptConnect(struct lws_sorted_usec_list *sul) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
IZ_ProcedureResult IZ_WSClientProtocolInitialize(struct lws* wsi, void* in) { |
|
|
IZ_ProcedureResult IZ_WSClientProtocolInitialize(struct lws* wsi, void* in) { |
|
|
IZ_WSClientVHostData* vhd_instance = (IZ_WSClientVHostData*) lws_protocol_vh_priv_get( |
|
|
|
|
|
lws_get_vhost(wsi), |
|
|
|
|
|
lws_get_protocol(wsi) |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
const struct lws_protocols* protocols = lws_get_protocol(wsi); |
|
|
|
|
|
struct lws_vhost* vhost = lws_get_vhost(wsi); |
|
|
|
|
|
IZ_WSClientVHostData* vhd_instance = (IZ_WSClientVHostData*) lws_protocol_vh_priv_get(vhost,protocols); |
|
|
IZ_WSClientVHostData** vhd = &vhd_instance; |
|
|
IZ_WSClientVHostData** vhd = &vhd_instance; |
|
|
*vhd = lws_protocol_vh_priv_zalloc( |
|
|
|
|
|
lws_get_vhost(wsi), |
|
|
|
|
|
lws_get_protocol(wsi), |
|
|
|
|
|
sizeof(IZ_WSClientVHostData) |
|
|
|
|
|
|
|
|
*vhd = lws_protocol_vh_priv_zalloc(vhost, protocols, sizeof(IZ_WSClientVHostData)); |
|
|
|
|
|
(*vhd)->ring = lws_ring_create( |
|
|
|
|
|
sizeof(IZ_WebsocketMessage), |
|
|
|
|
|
RING_COUNT, |
|
|
|
|
|
IZ_WebsocketDestroyMessage |
|
|
); |
|
|
); |
|
|
|
|
|
if (!(*vhd)->ring) { |
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
(*vhd)->context = lws_get_context(wsi); |
|
|
(*vhd)->context = lws_get_context(wsi); |
|
|
(*vhd)->protocol = lws_get_protocol(wsi); |
|
|
|
|
|
(*vhd)->vhost = lws_get_vhost(wsi); |
|
|
|
|
|
|
|
|
(*vhd)->protocol = protocols; |
|
|
|
|
|
(*vhd)->vhost = vhost; |
|
|
(*vhd)->port = (u16*) lws_pvo_search( |
|
|
(*vhd)->port = (u16*) lws_pvo_search( |
|
|
(const struct lws_protocol_vhost_options *)in, |
|
|
(const struct lws_protocol_vhost_options *)in, |
|
|
"port" |
|
|
"port" |
|
@@ -247,14 +250,6 @@ IZ_ProcedureResult IZ_WSClientProtocolInitialize(struct lws* wsi, void* in) { |
|
|
(const struct lws_protocol_vhost_options *)in, |
|
|
(const struct lws_protocol_vhost_options *)in, |
|
|
"app" |
|
|
"app" |
|
|
)->value; |
|
|
)->value; |
|
|
(*vhd)->ring = lws_ring_create( |
|
|
|
|
|
sizeof(IZ_WebsocketMessage), |
|
|
|
|
|
RING_COUNT, |
|
|
|
|
|
IZ_WebsocketDestroyMessage |
|
|
|
|
|
); |
|
|
|
|
|
if (!(*vhd)->ring) { |
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
|
|
|
IZ_WSClientAttemptConnect(&(*vhd)->sul); |
|
|
IZ_WSClientAttemptConnect(&(*vhd)->sul); |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
@@ -273,12 +268,11 @@ void IZ_WSClientProtocolTeardown(struct lws* wsi) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void IZ_WSClientConnectionError(struct lws* wsi, void* in) { |
|
|
void IZ_WSClientConnectionError(struct lws* wsi, void* in) { |
|
|
|
|
|
lwsl_err("CLIENT_CONNECTION_ERROR: %s\n", in ? (char *)in : "(null)"); |
|
|
IZ_WSClientVHostData* vhd = (IZ_WSClientVHostData*) lws_protocol_vh_priv_get( |
|
|
IZ_WSClientVHostData* vhd = (IZ_WSClientVHostData*) lws_protocol_vh_priv_get( |
|
|
lws_get_vhost(wsi), |
|
|
lws_get_vhost(wsi), |
|
|
lws_get_protocol(wsi) |
|
|
lws_get_protocol(wsi) |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
lwsl_err("CLIENT_CONNECTION_ERROR: %s\n", in ? (char *)in : "(null)"); |
|
|
|
|
|
IZ_App* app = (IZ_App*) vhd->app; |
|
|
IZ_App* app = (IZ_App*) vhd->app; |
|
|
app->net_state.ws.connection = NULL; |
|
|
app->net_state.ws.connection = NULL; |
|
|
vhd->client_wsi = NULL; |
|
|
vhd->client_wsi = NULL; |
|
@@ -292,17 +286,17 @@ void IZ_WSClientConnectionError(struct lws* wsi, void* in) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
IZ_ProcedureResult IZ_WSClientOnOpen(struct lws* wsi, IZ_WSClientSessionData* pss) { |
|
|
IZ_ProcedureResult IZ_WSClientOnOpen(struct lws* wsi, IZ_WSClientSessionData* pss) { |
|
|
|
|
|
pss->ring = lws_ring_create(sizeof(IZ_WebsocketMessage), RING_COUNT,IZ_WebsocketDestroyMessage); |
|
|
|
|
|
if (!pss->ring) { |
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
IZ_WSClientVHostData* vhd = (IZ_WSClientVHostData*) lws_protocol_vh_priv_get( |
|
|
IZ_WSClientVHostData* vhd = (IZ_WSClientVHostData*) lws_protocol_vh_priv_get( |
|
|
lws_get_vhost(wsi), |
|
|
lws_get_vhost(wsi), |
|
|
lws_get_protocol(wsi) |
|
|
lws_get_protocol(wsi) |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
IZ_App* app = (IZ_App*) vhd->app; |
|
|
IZ_App* app = (IZ_App*) vhd->app; |
|
|
app->net_state.ws.connection = wsi; |
|
|
app->net_state.ws.connection = wsi; |
|
|
pss->ring = lws_ring_create(sizeof(IZ_WebsocketMessage), RING_COUNT,IZ_WebsocketDestroyMessage); |
|
|
|
|
|
if (!pss->ring) { |
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
|
|
|
pss->tail = 0; |
|
|
pss->tail = 0; |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
@@ -312,7 +306,6 @@ void IZ_WSClientOnClose(struct lws* wsi) { |
|
|
lws_get_vhost(wsi), |
|
|
lws_get_vhost(wsi), |
|
|
lws_get_protocol(wsi) |
|
|
lws_get_protocol(wsi) |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
IZ_App* app = (IZ_App*) vhd->app; |
|
|
IZ_App* app = (IZ_App*) vhd->app; |
|
|
app->net_state.ws.connection = NULL; |
|
|
app->net_state.ws.connection = NULL; |
|
|
vhd->client_wsi = NULL; |
|
|
vhd->client_wsi = NULL; |
|
|