Callback method called by Strophe as the Connection goes through various states while establishing or tearing down a connection.
Switch to a different transport if a service URL is available for it.
When reconnecting with a new transport, we call setUserJID so that a new resource is generated, to avoid multiple server-side sessions with the same resource.
We also call
_proto._doDisconnect so that connection event handlers
for the old transport are removed.