- Wed Apr 19, 2017 7:51 am
That pointer points to an object which might be removed.
Here you can see that for every connect-event, a receive- and a disconnect-function are registered.
You should probably follow the object back to an IP and port; these will uniquely identify a remote host.
It is good practice if the server only
responds, so it does not intiate data-messages.
If you can write your server in such a fashion, that would lead to a clean client-server model.
In the receive-function you respond to a clients request, and then you forget all about it. Stateless.
In such a model the client sometimes polles to see if there's any data for him - so the initiative is Always with the client.
Ok, suppose you DO want to initiate data from the server.
In the connect event you get handed an object-pointer which can identify the connection.
I think you need to copy that object, or duplicate its data in your own espconn-struct, so you can call:
void espconn_sent(struct espconn *espconn, uint8 *psent, uint16 length);
So when you get the connection-callback, remember the data (preferably in a struct), and use that when you need to send data.