diff --git a/client.js b/client.js index abc95ed..929b8ed 100644 --- a/client.js +++ b/client.js @@ -103,9 +103,13 @@ function EventSourceWrapper() { } } - function handleDisconnect() { + function disconnect() { clearInterval(timer); source.close(); + } + + function handleDisconnect() { + disconnect(); setTimeout(init, options.timeout); } @@ -113,6 +117,7 @@ function EventSourceWrapper() { addMessageListener: function(fn) { listeners.push(fn); }, + disconnect: disconnect, }; }