[Libwebsockets] getting references to websocket private data
sagaert.johan at skynet.be
Wed Nov 5 17:25:30 CET 2014
Just getting started using libwebsockets.
I am using a global var and then use
to request sending data back to the client.
So this data gets sent in the callback function (case LWS_CALLBACK_SERVER_WRITEABLE) with the libwebsocket_write api.
This works, but I have no control over to wich remote client I can sent data.(every one receives the same data)
Is there some way I can get a reference to the private data structure associated with a websocket, so I can fill in the data to be
sent in this private struct that then would be sent in the callback function. (as in the test-echo example)
Do I need to create my own data structures/lists of connected clients and populate this in the callback function?
Next question is, how do I get the clients IP ?
lws_hdr_copy(wsi, buf, sizeof buf, WSI_TOKEN_KEY); is nog giving me the correct ip, it just gives me the site hosting the html/js
I want to know this ip so I can create a blacklist of ip's banned for some time when not they are not
sending the correct credentials in time.
Thanks in advance.
More information about the Libwebsockets