Implement keep-alive

Using a similar trick to rabbitmq, that is to check the bytes sent
whenever the timer fires to see if it's changed.

Needs a bit of refinement: if the timer is reset just before a packet
is sent, it may be almost two intervals before a pingreq is next
sent. The MQTT spec says that 3/2 an interval without traffic is
enough for the server to justify disconnecting the client.