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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 */ | 48 */ |
49 remoting.disconnect = function() { | 49 remoting.disconnect = function() { |
50 if (!remoting.clientSession) { | 50 if (!remoting.clientSession) { |
51 return; | 51 return; |
52 } | 52 } |
53 if (remoting.clientSession.getMode() == remoting.ClientSession.Mode.IT2ME) { | 53 if (remoting.clientSession.getMode() == remoting.ClientSession.Mode.IT2ME) { |
54 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME); | 54 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME); |
55 } else { | 55 } else { |
56 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME); | 56 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME); |
57 } | 57 } |
58 remoting.clientSession.disconnect(remoting.Error.NONE); | 58 remoting.app.onDisconnected(); |
59 remoting.clientSession = null; | 59 remoting.clientSession = null; |
60 console.log('Disconnected.'); | 60 console.log('Disconnected.'); |
61 }; | 61 }; |
62 | 62 |
63 /** | 63 /** |
64 * 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 |
65 * current and previous states are available via the |state| member variable. | 65 * current and previous states are available via the |state| member variable. |
66 * | 66 * |
67 * @param {remoting.ClientSession.StateEvent=} state | 67 * @param {remoting.ClientSession.StateEvent=} state |
68 */ | 68 */ |
69 function onClientStateChange_(state) { | 69 function onClientStateChange_(state) { |
70 switch (state.current) { | 70 switch (state.current) { |
71 case remoting.ClientSession.State.CLOSED: | 71 case remoting.ClientSession.State.CLOSED: |
72 console.log('Connection closed by host'); | 72 console.log('Connection closed by host'); |
73 if (remoting.clientSession.getMode() == | 73 if (remoting.clientSession.getMode() == |
74 remoting.ClientSession.Mode.IT2ME) { | 74 remoting.ClientSession.Mode.IT2ME) { |
75 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME); | 75 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME); |
76 remoting.hangoutSessionEvents.raiseEvent( | 76 remoting.hangoutSessionEvents.raiseEvent( |
77 remoting.hangoutSessionEvents.sessionStateChanged, | 77 remoting.hangoutSessionEvents.sessionStateChanged, |
78 remoting.ClientSession.State.CLOSED); | 78 remoting.ClientSession.State.CLOSED); |
79 } else { | 79 } else { |
80 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME); | 80 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME); |
81 } | 81 } |
| 82 remoting.app.onDisconnected(); |
82 break; | 83 break; |
83 | 84 |
84 case remoting.ClientSession.State.FAILED: | 85 case remoting.ClientSession.State.FAILED: |
85 var error = remoting.clientSession.getError(); | 86 var error = remoting.clientSession.getError(); |
86 console.error('Client plugin reported connection failed: ' + error); | 87 console.error('Client plugin reported connection failed: ' + error); |
87 if (error == null) { | 88 if (error == null) { |
88 error = remoting.Error.UNEXPECTED; | 89 error = remoting.Error.UNEXPECTED; |
89 } | 90 } |
90 remoting.app.onError(error); | 91 remoting.app.onError(error); |
91 break; | 92 break; |
(...skipping 20 matching lines...) Expand all Loading... |
112 remoting.clientSession.getState() != | 113 remoting.clientSession.getState() != |
113 remoting.ClientSession.State.CONNECTED) { | 114 remoting.ClientSession.State.CONNECTED) { |
114 return; | 115 return; |
115 } | 116 } |
116 var perfstats = remoting.clientSession.getPerfStats(); | 117 var perfstats = remoting.clientSession.getPerfStats(); |
117 remoting.stats.update(perfstats); | 118 remoting.stats.update(perfstats); |
118 remoting.clientSession.logStatistics(perfstats); | 119 remoting.clientSession.logStatistics(perfstats); |
119 // Update the stats once per second. | 120 // Update the stats once per second. |
120 window.setTimeout(updateStatistics_, 1000); | 121 window.setTimeout(updateStatistics_, 1000); |
121 } | 122 } |
OLD | NEW |