Show More
@@ -332,8 +332,11 b' define([' | |||||
332 | * @function reconnect |
|
332 | * @function reconnect | |
333 | */ |
|
333 | */ | |
334 | Kernel.prototype.reconnect = function () { |
|
334 | Kernel.prototype.reconnect = function () { | |
|
335 | if (this.is_connected()) { | |||
|
336 | return; | |||
|
337 | } | |||
335 | this.events.trigger('kernel_reconnecting.Kernel', {kernel: this}); |
|
338 | this.events.trigger('kernel_reconnecting.Kernel', {kernel: this}); | |
336 |
|
|
339 | this.start_channels(); | |
337 | }; |
|
340 | }; | |
338 |
|
341 | |||
339 | /** |
|
342 | /** | |
@@ -527,7 +530,15 b' define([' | |||||
527 | this._reconnect_attempt = this._reconnect_attempt + 1; |
|
530 | this._reconnect_attempt = this._reconnect_attempt + 1; | |
528 | this.events.trigger('kernel_connection_failed.Kernel', {kernel: this, ws_url: ws_url, attempt: this._reconnect_attempt}); |
|
531 | this.events.trigger('kernel_connection_failed.Kernel', {kernel: this, ws_url: ws_url, attempt: this._reconnect_attempt}); | |
529 | } |
|
532 | } | |
530 |
this.reconnect |
|
533 | if (this._reconnect_attempt < 7) { | |
|
534 | var timeout = Math.pow(2, this._reconnect_attempt); | |||
|
535 | console.log("Connection lost, reconnecting in " + timeout + " seconds."); | |||
|
536 | setTimeout($.proxy(this.reconnect, this), 1e3 * timeout); | |||
|
537 | } else { | |||
|
538 | this._reconnect_attempt = 1; | |||
|
539 | this.events.trigger('kernel_connection_given_up.Kernel', {kernel: this, ws_url: ws_url, attempt: this._reconnect_attempt}); | |||
|
540 | console.log("Failed to reconnect, giving up."); | |||
|
541 | } | |||
531 | }; |
|
542 | }; | |
532 |
|
543 | |||
533 | /** |
|
544 | /** |
General Comments 0
You need to be logged in to leave comments.
Login now