| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * Functions related to the 'client screen' for Chromoting. | 7 * Functions related to the 'client screen' for Chromoting. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 ('hidden' in document) ? document.hidden : document.webkitHidden); | 46 ('hidden' in document) ? document.hidden : document.webkitHidden); |
| 47 } | 47 } |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * Disconnect the remoting client. | 51 * Disconnect the remoting client. |
| 52 * | 52 * |
| 53 * @return {void} Nothing. | 53 * @return {void} Nothing. |
| 54 */ | 54 */ |
| 55 remoting.disconnect = function() { | 55 remoting.disconnect = function() { |
| 56 if (!remoting.desktopConnectedView) { | 56 if (!remoting.clientSession) { |
| 57 return; | 57 return; |
| 58 } | 58 } |
| 59 if (remoting.desktopConnectedView.getMode() == | 59 remoting.clientSession.disconnect(remoting.Error.NONE); |
| 60 remoting.DesktopConnectedView.Mode.IT2ME) { | |
| 61 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME); | |
| 62 } else { | |
| 63 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME); | |
| 64 } | |
| 65 remoting.app.onDisconnected(); | |
| 66 remoting.clientSession = null; | |
| 67 remoting.desktopConnectedView = null; | |
| 68 console.log('Disconnected.'); | 60 console.log('Disconnected.'); |
| 69 }; | 61 }; |
| 70 | 62 |
| 71 /** | 63 /** |
| 72 * Callback function called when the state of the client plugin changes. The | 64 * Callback function called when the state of the client plugin changes. The |
| 73 * current and previous states are available via the |state| member variable. | 65 * current and previous states are available via the |state| member variable. |
| 74 * | 66 * |
| 75 * @param {remoting.ClientSession.StateEvent=} state | 67 * @param {remoting.ClientSession.StateEvent=} state |
| 76 */ | 68 */ |
| 77 function onClientStateChange_(state) { | 69 function onClientStateChange_(state) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 104 // This should only happen if the web-app and client plugin get out of | 96 // This should only happen if the web-app and client plugin get out of |
| 105 // sync, so MISSING_PLUGIN is a suitable error. | 97 // sync, so MISSING_PLUGIN is a suitable error. |
| 106 remoting.app.onError(remoting.Error.MISSING_PLUGIN); | 98 remoting.app.onError(remoting.Error.MISSING_PLUGIN); |
| 107 break; | 99 break; |
| 108 } | 100 } |
| 109 | 101 |
| 110 remoting.clientSession.removeEventListener('stateChanged', | 102 remoting.clientSession.removeEventListener('stateChanged', |
| 111 onClientStateChange_); | 103 onClientStateChange_); |
| 112 remoting.clientSession.cleanup(); | 104 remoting.clientSession.cleanup(); |
| 113 remoting.clientSession = null; | 105 remoting.clientSession = null; |
| 106 remoting.desktopConnectedView = null; |
| 114 } | 107 } |
| 115 | 108 |
| 116 /** | 109 /** |
| 117 * Timer callback to update the statistics panel. | 110 * Timer callback to update the statistics panel. |
| 118 */ | 111 */ |
| 119 function updateStatistics_() { | 112 function updateStatistics_() { |
| 120 if (!remoting.clientSession || | 113 if (!remoting.clientSession || |
| 121 remoting.clientSession.getState() != | 114 remoting.clientSession.getState() != |
| 122 remoting.ClientSession.State.CONNECTED) { | 115 remoting.ClientSession.State.CONNECTED) { |
| 123 return; | 116 return; |
| 124 } | 117 } |
| 125 var perfstats = remoting.clientSession.getPerfStats(); | 118 var perfstats = remoting.clientSession.getPerfStats(); |
| 126 remoting.stats.update(perfstats); | 119 remoting.stats.update(perfstats); |
| 127 remoting.clientSession.logStatistics(perfstats); | 120 remoting.clientSession.logStatistics(perfstats); |
| 128 // Update the stats once per second. | 121 // Update the stats once per second. |
| 129 window.setTimeout(updateStatistics_, 1000); | 122 window.setTimeout(updateStatistics_, 1000); |
| 130 } | 123 } |
| OLD | NEW |