Only emit disconnected event if previously connected.

This commit is contained in:
Julien Fontanet 2015-02-10 18:13:01 +01:00
parent ae4af99c59
commit 0b4f808b2d

View File

@ -161,7 +161,10 @@ assign(Api.prototype, {
this_._jsonRpc.failPendingRequests(new ConnectionLost());
this_.emit('disconnected');
// Only emit this event if connected before.
if (deferred.promise.isFulfilled()) {
this_.emit('disconnected');
}
});
socket.addEventListener('error', function (error) {