|
@@ -66,7 +66,7 @@ IZ_ProcedureResult IZ_NetInitialize( |
|
|
if (!user_data) { |
|
|
if (!user_data) { |
|
|
return -2; |
|
|
return -2; |
|
|
} |
|
|
} |
|
|
state->ws.user_data = user_data; |
|
|
|
|
|
|
|
|
state->binding.user_data = user_data; |
|
|
state->callback = callback; |
|
|
state->callback = callback; |
|
|
state->retries = state->config.max_reconnect_retries; |
|
|
state->retries = state->config.max_reconnect_retries; |
|
|
u8 player_index; |
|
|
u8 player_index; |
|
@@ -96,7 +96,7 @@ void IZ_NetConnect(IZ_NetState* state, IZ_WSClientInitializeParams params) { |
|
|
|
|
|
|
|
|
state->retries = 0; |
|
|
state->retries = 0; |
|
|
state->params = params; |
|
|
state->params = params; |
|
|
state->client_thread = SDL_CreateThread(state->callback, "networking", state->ws.user_data); |
|
|
|
|
|
|
|
|
state->client_thread = SDL_CreateThread(state->callback, "networking", state->binding.user_data); |
|
|
SDL_DetachThread(state->client_thread); |
|
|
SDL_DetachThread(state->client_thread); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -104,17 +104,17 @@ void IZ_NetDisconnect(IZ_NetState* state) { |
|
|
if (state->status == IZ_NET_STATUS_PRISTINE) { |
|
|
if (state->status == IZ_NET_STATUS_PRISTINE) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
if (state->ws.connection) { |
|
|
|
|
|
|
|
|
if (state->binding.connection) { |
|
|
IZ_WSClientVHostData *vhd = (IZ_WSClientVHostData *) lws_protocol_vh_priv_get( |
|
|
IZ_WSClientVHostData *vhd = (IZ_WSClientVHostData *) lws_protocol_vh_priv_get( |
|
|
lws_get_vhost(state->ws.connection), |
|
|
|
|
|
lws_get_protocol(state->ws.connection) |
|
|
|
|
|
|
|
|
lws_get_vhost(state->binding.connection), |
|
|
|
|
|
lws_get_protocol(state->binding.connection) |
|
|
); |
|
|
); |
|
|
if (vhd) { |
|
|
if (vhd) { |
|
|
lws_sul_cancel(&vhd->sul); |
|
|
lws_sul_cancel(&vhd->sul); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
state->retries = state->config.max_reconnect_retries; |
|
|
state->retries = state->config.max_reconnect_retries; |
|
|
IZ_WSClientCancelService(&state->ws); |
|
|
|
|
|
|
|
|
IZ_WSClientCancelService(&state->binding); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void IZ_NetSendBinaryMessage(IZ_NetState* state, void* in, size_t len) { |
|
|
void IZ_NetSendBinaryMessage(IZ_NetState* state, void* in, size_t len) { |
|
@@ -123,20 +123,20 @@ void IZ_NetSendBinaryMessage(IZ_NetState* state, void* in, size_t len) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
IZ_WSClientVHostData* vhd = (IZ_WSClientVHostData*) lws_protocol_vh_priv_get( |
|
|
IZ_WSClientVHostData* vhd = (IZ_WSClientVHostData*) lws_protocol_vh_priv_get( |
|
|
lws_get_vhost(state->ws.connection), |
|
|
|
|
|
lws_get_protocol(state->ws.connection) |
|
|
|
|
|
|
|
|
lws_get_vhost(state->binding.connection), |
|
|
|
|
|
lws_get_protocol(state->binding.connection) |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
IZ_WebsocketMessage amsg; |
|
|
IZ_WebsocketMessage amsg; |
|
|
i32 result; |
|
|
i32 result; |
|
|
result = IZ_WebsocketCreateBinaryMessage(state->ws.connection, &amsg, in, len); |
|
|
|
|
|
|
|
|
result = IZ_WebsocketCreateBinaryMessage(state->binding.connection, &amsg, in, len); |
|
|
|
|
|
|
|
|
if (result < 0) { |
|
|
if (result < 0) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
lws_ring_insert(vhd->ring, &amsg, 1); |
|
|
lws_ring_insert(vhd->ring, &amsg, 1); |
|
|
lws_callback_on_writable(state->ws.connection); |
|
|
|
|
|
|
|
|
lws_callback_on_writable(state->binding.connection); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void IZ_NetSendTextMessage(IZ_NetState* state, char* in, size_t len) { |
|
|
void IZ_NetSendTextMessage(IZ_NetState* state, char* in, size_t len) { |
|
@@ -145,18 +145,18 @@ void IZ_NetSendTextMessage(IZ_NetState* state, char* in, size_t len) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
IZ_WSClientVHostData* vhd = (IZ_WSClientVHostData*) lws_protocol_vh_priv_get( |
|
|
IZ_WSClientVHostData* vhd = (IZ_WSClientVHostData*) lws_protocol_vh_priv_get( |
|
|
lws_get_vhost(state->ws.connection), |
|
|
|
|
|
lws_get_protocol(state->ws.connection) |
|
|
|
|
|
|
|
|
lws_get_vhost(state->binding.connection), |
|
|
|
|
|
lws_get_protocol(state->binding.connection) |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
IZ_WebsocketMessage amsg; |
|
|
IZ_WebsocketMessage amsg; |
|
|
i32 result; |
|
|
i32 result; |
|
|
result = IZ_WebsocketCreateTextMessage(state->ws.connection, &amsg, in, len); |
|
|
|
|
|
|
|
|
result = IZ_WebsocketCreateTextMessage(state->binding.connection, &amsg, in, len); |
|
|
|
|
|
|
|
|
if (result < 0) { |
|
|
if (result < 0) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
lws_ring_insert(vhd->ring, &amsg, 1); |
|
|
lws_ring_insert(vhd->ring, &amsg, 1); |
|
|
lws_callback_on_writable(state->ws.connection); |
|
|
|
|
|
|
|
|
lws_callback_on_writable(state->binding.connection); |
|
|
} |
|
|
} |