libwebsock lws_protocols callback and name

13 Views Asked by At

From libwebsocket server site example. it working, but the resson LWS_CALLBACK_RECEIVE always get into callback_http(), in case of below javasript. How to make LWS_CALLBACK_RECEIVE get into callback_example()

Javasript client

let socket = new WebSocket("ws://172.16.20.202:8001/example-protocol");

example libwebsocket server

static struct lws_protocols protocols[] =
{
        /* The first protocol must always be the HTTP handler */
        {
                "http-only",   /* name */
                callback_http, /* callback */
                0,             /* No per session data. */
                0,             /* max frame size / rx buffer */
        },
        {
                "example-protocol",
                callback_example,
                sizeof(per_session_data),
                EXAMPLE_RX_BUFFER_BYTES,
        },
        { NULL, NULL, 0, 0 } /* terminator */
};
0

There are 0 best solutions below