Closed alexe100 closed 4 years ago
Hello,
A websocket service is a http service first, the websocket part is kind of an extension of the http connection. Therefore to connect to a websocket, you need to know its http address first. That's why on ulfius, you can start a websocket server only inside an endpoint callback. Maybe the documentation isn't clear about that. If you want the websocket to be available for all addresses of your webserver, you can create a unique endpoint and open it for all addresses:
ulfius_add_endpoint_by_val(&instance, "GET", NULL, "*", 0, &callback_function, NULL);
Note that a websocket must be accessed using a GET
method.
Got it! Thank you
Hello, me again... In the websocket_server sample it seems that websocket is opened because there is a rest endpoint that points to the main callback_websocket function, right?
Documentation refers function ulfius_start_websocket_cb to be used to start server side websockets but then there is not more details about this function e.g. syntax. Instead ulfius_set_websocket_response is presented next. Is this a documentation bug or is it like that?
My doubt here is how to create and open server side websocket without relying in rest api (a server that serves only websocket and zero rest api)?
Sorry about all these posts :-( but your framework seems very very interesting and flexible when compared with similar ones.
Alex