void websocket_server_ready(struct mg_connection * conn, void * _ignored) #endif { printf("Server: Websocket ready\n"); /* Send websocket welcome message */ mg_lock_connection(conn); mg_websocket_write(conn, WEBSOCKET_OPCODE_TEXT, websocket_welcome_msg, websocket_welcome_msg_len); mg_unlock_connection(conn); }
int websocket_server_data(struct mg_connection * conn, int bits, char *data, size_t data_len, void *_ignored) #endif { printf("Server: Got %u bytes from the client\n", data_len); if (data_len<3 || 0!=memcmp(data, "bye", 3)) { /* Send websocket acknowledge message */ mg_lock_connection(conn); mg_websocket_write(conn, WEBSOCKET_OPCODE_TEXT, websocket_acknowledge_msg, websocket_acknowledge_msg_len); mg_unlock_connection(conn); } else { /* Send websocket acknowledge message */ mg_lock_connection(conn); mg_websocket_write(conn, WEBSOCKET_OPCODE_TEXT, websocket_goodbye_msg, websocket_goodbye_msg_len); mg_unlock_connection(conn); } return 1; /* return 1 to keep the connetion open */ }
static void websock_server_ready(struct mg_connection *conn, void *udata) { ck_assert_ptr_eq((void *)udata, (void *)7531); printf("Server: Websocket ready\n"); /* Send websocket welcome message */ mg_lock_connection(conn); mg_websocket_write(conn, WEBSOCKET_OPCODE_TEXT, websocket_welcome_msg, websocket_welcome_msg_len); mg_unlock_connection(conn); printf("Server: Websocket ready X\n"); }