| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * It2MeService listens to incoming connections requests from Hangouts | 7 * It2MeService listens to incoming connections requests from Hangouts |
| 8 * and the webapp and creates a It2MeHelperChannel between them. | 8 * and the webapp and creates a It2MeHelperChannel between them. |
| 9 * It supports multiple helper sessions, but only a single helpee. | 9 * It supports multiple helper sessions, but only a single helpee. |
| 10 */ | 10 */ |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 switch (port.name) { | 72 switch (port.name) { |
| 73 case ConnectionTypes.HELPER_HANGOUT: | 73 case ConnectionTypes.HELPER_HANGOUT: |
| 74 this.handleExternalHelperConnection_(port); | 74 this.handleExternalHelperConnection_(port); |
| 75 return true; | 75 return true; |
| 76 case ConnectionTypes.HELPEE_HANGOUT: | 76 case ConnectionTypes.HELPEE_HANGOUT: |
| 77 this.handleExternalHelpeeConnection_(port); | 77 this.handleExternalHelpeeConnection_(port); |
| 78 return true; | 78 return true; |
| 79 default: | 79 default: |
| 80 throw new Error('Unsupported port - ' + port.name); | 80 throw new Error('Unsupported port - ' + port.name); |
| 81 } | 81 } |
| 82 } catch (e) { | 82 } catch (/** @type {*} */ e) { |
| 83 var error = /**@type {Error} */ e; | 83 var error = /**@type {Error} */ (e); |
| 84 console.error(error); | 84 console.error(error); |
| 85 port.disconnect(); | 85 port.disconnect(); |
| 86 } | 86 } |
| 87 return false; | 87 return false; |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 /** | 90 /** |
| 91 * @param {chrome.runtime.Port} port | 91 * @param {chrome.runtime.Port} port |
| 92 * @private | 92 * @private |
| 93 */ | 93 */ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 104 if (portName === ConnectionTypes.HELPER_WEBAPP && senderId !== undefined) { | 104 if (portName === ConnectionTypes.HELPER_WEBAPP && senderId !== undefined) { |
| 105 for (var i = 0; i < this.helpers_.length; i++) { | 105 for (var i = 0; i < this.helpers_.length; i++) { |
| 106 var helper = this.helpers_[i]; | 106 var helper = this.helpers_[i]; |
| 107 if (helper.instanceId() === senderId) { | 107 if (helper.instanceId() === senderId) { |
| 108 helper.onWebappConnect(port, senderId); | 108 helper.onWebappConnect(port, senderId); |
| 109 return; | 109 return; |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 throw new Error('No matching hangout connection found for ' + port.name); | 113 throw new Error('No matching hangout connection found for ' + port.name); |
| 114 } catch (e) { | 114 } catch (/** @type {*} */ e) { |
| 115 var error = /** @type {Error} */ e; | 115 var error = /** @type {Error} */ (e); |
| 116 console.error(error); | 116 console.error(error); |
| 117 port.disconnect(); | 117 port.disconnect(); |
| 118 } | 118 } |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 /** | 121 /** |
| 122 * @param {remoting.It2MeHelperChannel} helper | 122 * @param {remoting.It2MeHelperChannel} helper |
| 123 */ | 123 */ |
| 124 remoting.It2MeService.prototype.onHelperChannelDisconnected = function(helper) { | 124 remoting.It2MeService.prototype.onHelperChannelDisconnected = function(helper) { |
| 125 for (var i = 0; i < this.helpers_.length; i++) { | 125 for (var i = 0; i < this.helpers_.length; i++) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 return; | 166 return; |
| 167 } | 167 } |
| 168 | 168 |
| 169 console.log('Incoming helpee connection from Hangouts'); | 169 console.log('Incoming helpee connection from Hangouts'); |
| 170 this.helpee_ = new remoting.It2MeHelpeeChannel( | 170 this.helpee_ = new remoting.It2MeHelpeeChannel( |
| 171 hangoutPort, | 171 hangoutPort, |
| 172 new remoting.It2MeHostFacade(), | 172 new remoting.It2MeHostFacade(), |
| 173 new remoting.HostInstaller(), | 173 new remoting.HostInstaller(), |
| 174 this.onHelpeeChannelDisconnected.bind(this)); | 174 this.onHelpeeChannelDisconnected.bind(this)); |
| 175 this.helpee_.init(); | 175 this.helpee_.init(); |
| 176 }; | 176 }; |
| OLD | NEW |