When we didn't and one was still alive, it might do a callback on the
class after the destructor.
Deleting them makes the callbacks be removed on the server, avoiding
usage after free.
Rename variable to talk about message instead of package (which probably
was meant to be packet anyway).
Make log message of exception we caught a little more useful.
The onDisconnected callback is moved to later in the process after the
internal state has been updated so calling 'isConnected()' is what you'd
expect.
This reverts commit e28b5e1823.
The port number is again passed through the dns lookup, which is
weird as fuck but needed to get the actual resulting iterator still
have the port numebr we wanted to connect to.
A connection that is 'shutdown' now ensures one more time we'll call
onDisconnected() (is it was..) allowing the application level logic to
get notified and avoid memory leaks.
When the user-layer triggers a re-connect instead of waiting for the
layer to re-connect then we should avoid doing work twice.
This also avoids a reconnect in some cases.
As we moved most of the creation of a BufferPool to be via the
Streaming::pool() method, which uses a thread-local, it makes sense
to start cleaning up the design and make it more modern C++.
The above mentioned method would return a reference and you'd see
loads of places use `auto &pool =` which is less than ideal.
As the number of places where we actually instantiate a BufferPool
goes down, the usage of some sort of smart pointer makes more sense.
This now makes all APIs use BufferPool be wrapped in a shared_ptr.
Avoid massive connect storm.
Using the network manager based logger we got into a fun situation where
logging to a remote host caused us to connect and fail, which caused us
to log this failed which made us try to connect and .. etc.
The server always sends pongs in response to our pings, but we assumed
that the underlying OS would close a connection when the other side
isn't replying (ACKs).
Now we take this responsibility in the code and when no pongs are
registered we also close and re-establish the connection.
This additionally shortens the ping time to 30 seconds and the timeout
to 90 seconds.