1
0
mirror of https://github.com/lammertb/libhttp.git synced 2025-07-29 21:01:13 +03:00

Websocket example should show creation and deletion of websocket connections

This commit is contained in:
bel
2014-01-12 14:13:51 +01:00
parent c471b9bdc9
commit 6766951f38
2 changed files with 5 additions and 3 deletions

View File

@ -73,6 +73,7 @@ void websocket_ready_handler(struct mg_connection *conn) {
break;
}
}
printf("\nNew websocket attached: %08x:%u\n", rq->remote_ip, rq->remote_port);
pthread_mutex_unlock(&sMutex);
}
@ -87,6 +88,7 @@ static void websocket_done(tWebSockInfo * wsock) {
break;
}
}
printf("\nClose websocket attached: %08x:%u\n", mg_get_request_info(wsock->conn)->remote_ip, mg_get_request_info(wsock->conn)->remote_port);
free(wsock);
}
}
@ -185,8 +187,8 @@ void websock_send_broadcast(const char * data, int data_len) {
if (data_len<=256) {
strcpy(buffer, "msg ");
memcpy(buffer+4, data, data_len);
pthread_mutex_lock(&sMutex);
pthread_mutex_lock(&sMutex);
send_to_all_websockets(buffer, data_len+4);
pthread_mutex_unlock(&sMutex);
}