OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 * Connect set-up state machine for Me2Me and IT2Me | 7 * Connect set-up state machine for Me2Me and IT2Me |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
11 | 11 |
12 /** @suppress {duplicate} */ | 12 /** @suppress {duplicate} */ |
13 var remoting = remoting || {}; | 13 var remoting = remoting || {}; |
14 | 14 |
15 /** | 15 /** |
16 * @type {remoting.ClientSession} The client session object, set once the | |
17 * connector has invoked its onOk callback. | |
18 * TODO(garykac): Have this owned by someone instead of being global. | |
19 */ | |
20 remoting.clientSession; | |
21 | |
22 /** | |
23 * @param {HTMLElement} clientContainer Container element for the client view. | 16 * @param {HTMLElement} clientContainer Container element for the client view. |
24 * @param {Array<string>} requiredCapabilities Connector capabilities | 17 * @param {Array<string>} requiredCapabilities Connector capabilities |
25 * required by this application. | 18 * required by this application. |
26 * @param {remoting.ClientSession.EventHandler} handler | 19 * @param {remoting.ClientSession.EventHandler} handler |
27 * @constructor | 20 * @constructor |
28 * @implements {remoting.SessionConnector} | 21 * @implements {remoting.SessionConnector} |
29 */ | 22 */ |
30 remoting.SessionConnectorImpl = | 23 remoting.SessionConnectorImpl = |
31 function(clientContainer, requiredCapabilities, handler) { | 24 function(clientContainer, requiredCapabilities, handler) { |
32 /** @private {HTMLElement} */ | 25 /** @private {HTMLElement} */ |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 61 |
69 /** @private {remoting.Host} */ | 62 /** @private {remoting.Host} */ |
70 this.host_ = null; | 63 this.host_ = null; |
71 | 64 |
72 /** @private {boolean} */ | 65 /** @private {boolean} */ |
73 this.logHostOfflineErrors_ = false; | 66 this.logHostOfflineErrors_ = false; |
74 | 67 |
75 base.dispose(this.clientSession_); | 68 base.dispose(this.clientSession_); |
76 /** @private {remoting.ClientSession} */ | 69 /** @private {remoting.ClientSession} */ |
77 this.clientSession_ = null; | 70 this.clientSession_ = null; |
78 remoting.clientSession = null; | |
79 | 71 |
80 base.dispose(this.plugin_); | 72 base.dispose(this.plugin_); |
81 /** @private {remoting.ClientPlugin} */ | 73 /** @private {remoting.ClientPlugin} */ |
82 this.plugin_ = null; | 74 this.plugin_ = null; |
83 | 75 |
84 /** @private {remoting.CredentialsProvider} */ | 76 /** @private {remoting.CredentialsProvider} */ |
85 this.credentialsProvider_ = null; | 77 this.credentialsProvider_ = null; |
86 | 78 |
87 base.dispose(this.signalStrategy_); | 79 base.dispose(this.signalStrategy_); |
88 /** @private {remoting.SignalStrategy} */ | 80 /** @private {remoting.SignalStrategy} */ |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 194 |
203 if (!this.plugin_.isSupportedVersion()) { | 195 if (!this.plugin_.isSupportedVersion()) { |
204 console.error('ERROR: bad plugin version'); | 196 console.error('ERROR: bad plugin version'); |
205 this.pluginError_(new remoting.Error( | 197 this.pluginError_(new remoting.Error( |
206 remoting.Error.Tag.BAD_PLUGIN_VERSION)); | 198 remoting.Error.Tag.BAD_PLUGIN_VERSION)); |
207 return; | 199 return; |
208 } | 200 } |
209 | 201 |
210 this.clientSession_ = new remoting.ClientSession( | 202 this.clientSession_ = new remoting.ClientSession( |
211 this.plugin_, this.host_, this.signalStrategy_); | 203 this.plugin_, this.host_, this.signalStrategy_); |
212 remoting.clientSession = this.clientSession_; | |
213 | 204 |
214 this.clientSession_.logHostOfflineErrors(this.logHostOfflineErrors_); | 205 this.clientSession_.logHostOfflineErrors(this.logHostOfflineErrors_); |
215 this.eventHook_ = new base.EventHook( | 206 this.eventHook_ = new base.EventHook( |
216 this.clientSession_, 'stateChanged', this.onStateChange_.bind(this)); | 207 this.clientSession_, 'stateChanged', this.onStateChange_.bind(this)); |
217 this.plugin_.connect( | 208 this.plugin_.connect( |
218 this.host_, this.signalStrategy_.getJid(), this.credentialsProvider_); | 209 this.host_, this.signalStrategy_.getJid(), this.credentialsProvider_); |
219 }; | 210 }; |
220 | 211 |
221 /** | 212 /** |
222 * @param {!remoting.Error} error | 213 * @param {!remoting.Error} error |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 * @param {Array<string>} requiredCapabilities Connector capabilities | 282 * @param {Array<string>} requiredCapabilities Connector capabilities |
292 * required by this application. | 283 * required by this application. |
293 * @param {remoting.ClientSession.EventHandler} handler | 284 * @param {remoting.ClientSession.EventHandler} handler |
294 * @return {remoting.SessionConnector} | 285 * @return {remoting.SessionConnector} |
295 */ | 286 */ |
296 remoting.DefaultSessionConnectorFactory.prototype.createConnector = | 287 remoting.DefaultSessionConnectorFactory.prototype.createConnector = |
297 function(clientContainer, requiredCapabilities, handler) { | 288 function(clientContainer, requiredCapabilities, handler) { |
298 return new remoting.SessionConnectorImpl(clientContainer, | 289 return new remoting.SessionConnectorImpl(clientContainer, |
299 requiredCapabilities, handler); | 290 requiredCapabilities, handler); |
300 }; | 291 }; |
OLD | NEW |