dhruvbird/node-xmpp-bosh — pull request #79 by gavllew (2013-05-21 17:19:13+00:00)
Title: Further stream close improvements; addition of WebSocket ping

I was seeing some server restarts on occasion when a websocket client closes a connection - the XMPP server would attempt to distribute the unavailable presence, and this would get passed to the closed websocket server, throwing an uncaught exception.

In attempting to fix this, I ended up reworking a lot of the stream/connection close code - it should now be compliant with section 3.5 of draft-moffitt-xmpp-over-websocket-03 (i.e. respond to a stream close with another stream close, and let the initiator send the websocket close frame).

It also now sends a websocket ping frame every thirty seconds for each connection, and checks for the 'pong' response. This is for the following reasons:
* Keep idle sessions from getting dropped by intermediate load balancers/proxies/NAT firewalls.
* Close the connection if the client disappears unexpectedly.