| Index: remoting/webapp/crd/js/smart_reconnector.js
|
| diff --git a/remoting/webapp/crd/js/smart_reconnector.js b/remoting/webapp/crd/js/smart_reconnector.js
|
| index 3ad4d6f4ab48f7110a3842472bffa3e121907bea..afb6975a916176decb762439b83179442eb2fe0d 100644
|
| --- a/remoting/webapp/crd/js/smart_reconnector.js
|
| +++ b/remoting/webapp/crd/js/smart_reconnector.js
|
| @@ -21,6 +21,7 @@ var remoting = remoting || {};
|
|
|
| /**
|
| * @constructor
|
| + * @param {remoting.ConnectingDialog} connectingDialog
|
| * @param {function()} reconnectCallback
|
| * @param {function()} disconnectCallback
|
| * @param {remoting.ClientSession} clientSession This represents the current
|
| @@ -28,8 +29,8 @@ var remoting = remoting || {};
|
| * connection state.
|
| * @implements {base.Disposable}
|
| */
|
| -remoting.SmartReconnector =
|
| - function(reconnectCallback, disconnectCallback, clientSession) {
|
| +remoting.SmartReconnector = function(connectingDialog, reconnectCallback,
|
| + disconnectCallback, clientSession) {
|
| /** @private */
|
| this.reconnectCallback_ = reconnectCallback;
|
|
|
| @@ -47,13 +48,14 @@ remoting.SmartReconnector =
|
| */
|
| this.pending_ = null;
|
|
|
| + /** @private */
|
| + this.connectingDialog_ = connectingDialog;
|
| +
|
| var Events = remoting.ClientSession.Events;
|
| /** @private */
|
| - this.eventHooks_ = new base.Disposables(
|
| - new base.EventHook(clientSession, Events.stateChanged,
|
| - this.stateChanged_.bind(this)),
|
| + this.eventHook_ =
|
| new base.EventHook(clientSession, Events.videoChannelStateChanged,
|
| - this.videoChannelStateChanged_.bind(this)));
|
| + this.videoChannelStateChanged_.bind(this));
|
| };
|
|
|
| // The online event only means the network adapter is enabled, but
|
| @@ -68,30 +70,26 @@ var CONNECTION_TIMEOUT_MS = 10000;
|
| remoting.SmartReconnector.prototype.reconnect_ = function() {
|
| this.cancelPending_();
|
| this.disconnectCallback_();
|
| - remoting.setMode(remoting.AppMode.CLIENT_CONNECTING);
|
| this.reconnectCallback_();
|
| };
|
|
|
| remoting.SmartReconnector.prototype.reconnectAsync_ = function() {
|
| this.cancelPending_();
|
| - remoting.setMode(remoting.AppMode.CLIENT_CONNECTING);
|
| + this.connectingDialog_.show();
|
| this.pending_ =
|
| new base.OneShotTimer(this.reconnect_.bind(this), RECONNECT_DELAY_MS);
|
| };
|
|
|
| /**
|
| - * @param {remoting.ClientSession.StateEvent=} event
|
| + * @param {!remoting.Error} reason
|
| */
|
| -remoting.SmartReconnector.prototype.stateChanged_ = function(event) {
|
| - var State = remoting.ClientSession.State;
|
| - if (event.previous === State.CONNECTED && event.current === State.FAILED) {
|
| - this.cancelPending_();
|
| - if (navigator.onLine) {
|
| - this.reconnect_();
|
| - } else {
|
| - this.pending_ = new base.DomEventHook(
|
| - window, 'online', this.reconnectAsync_.bind(this), false);
|
| - }
|
| +remoting.SmartReconnector.prototype.onConnectionDropped = function(reason) {
|
| + this.cancelPending_();
|
| + if (navigator.onLine) {
|
| + this.reconnect_();
|
| + } else {
|
| + this.pending_ = new base.DomEventHook(
|
| + window, 'online', this.reconnectAsync_.bind(this), false);
|
| }
|
| };
|
|
|
| @@ -121,8 +119,8 @@ remoting.SmartReconnector.prototype.cancelPending_ = function() {
|
|
|
| remoting.SmartReconnector.prototype.dispose = function() {
|
| this.cancelPending_();
|
| - base.dispose(this.eventHooks_);
|
| - this.eventHooks_ = null;
|
| + base.dispose(this.eventHook_);
|
| + this.eventHook_ = null;
|
| };
|
|
|
| })();
|
|
|