Set reconnect=true, add error trace to help detect disconnects

Added to help resolve issue https://github.com/uProxy/uProxy/issues/224

Setting reconnect=true should result in the Client object automatically trying to reconnect to XMPP in case of an error.  I've also added error trace to offline, close, and end events in the client to help us debug if these occur.

I'm not sure how to force the XMPP network to disconnect me, so don't know the best way to test this.  Right now I've been able to trigger the close event by calling client.connection.socket.destroy().  I don't see the end or offline events being fired yet, but I think trace here is a good idea so we can better debug when logouts do occur.
+1 also +1 for onLogout. Been wanting that for a long while.
On Jun 18, 2014 8:36 AM, "dborkan" <notifications@github.com> wrote:

> In src/socialprovider.js:
>
> > @@ -157,6 +158,23 @@ XMPPSocialProvider.prototype.connect = function(continuation) {
> >        delete this.client;
> >      }
> >    }.bind(this));
> > +  this.client.addListener('offline', function(e) {
> > +    // TODO: tell users of the API that this client is now offline,
> > +    // either by emitting an onClientState with OFFLINE using:
> > +    //   this.vCardStore.updateProperty(this.id, 'status', 'OFFLINE');
> > +    // or emit a new type of event, or invoke this.logout directly to
> > +    // clean things up.
> > +    console.error('received unhandled offline event', e);
>
> We could do that, but it seems to me that it won't be the clearest API.
> For example, if we emit a clientState indicating that the signed in client
> is now offline, should the caller of the API be expected to then call
> logout? Or should socialprovider.js itself have called logout? If nobody
> calls logout then I think the API object is just left in a weird offline
> state and won't be usable until someone calls logout then login again.
>
> I'm thinking maybe it would be better have a new onLogout message emitted
> to the API user - but that is a bigger change.
>
> In any case, I'd like to bump up the npm version number so this can be
> included in uProxy. We are getting lots of bug reports that include logs,
> and if we have this trace added it will be much easier to figure out whats
> going on, even if there is no new functionality (outside of reconnect=true
> in the connectOpts)
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/freedomjs/freedom-social-xmpp/pull/49/files#r13921885>
> .
>