| 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 * Class handling creation and teardown of a remoting client session. | 7 * Class handling creation and teardown of a remoting client session. |
| 8 * | 8 * |
| 9 * The ClientSession class controls lifetime of the client plugin | 9 * The ClientSession class controls lifetime of the client plugin |
| 10 * object and provides the plugin with the functionality it needs to | 10 * object and provides the plugin with the functionality it needs to |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 * @private */ | 99 * @private */ |
| 100 this.plugin_ = null; | 100 this.plugin_ = null; |
| 101 /** @private */ | 101 /** @private */ |
| 102 this.shrinkToFit_ = true; | 102 this.shrinkToFit_ = true; |
| 103 /** @private */ | 103 /** @private */ |
| 104 this.resizeToClient_ = true; | 104 this.resizeToClient_ = true; |
| 105 /** @private */ | 105 /** @private */ |
| 106 this.remapKeys_ = ''; | 106 this.remapKeys_ = ''; |
| 107 /** @private */ | 107 /** @private */ |
| 108 this.hasReceivedFrame_ = false; | 108 this.hasReceivedFrame_ = false; |
| 109 this.logToServer = new remoting.LogToServer(signalStrategy); | 109 this.logToServer = new remoting.LogToServer(signalStrategy, mode); |
| 110 | 110 |
| 111 /** @private */ | 111 /** @private */ |
| 112 this.signalStrategy_ = signalStrategy; | 112 this.signalStrategy_ = signalStrategy; |
| 113 base.debug.assert(this.signalStrategy_.getState() == | 113 base.debug.assert(this.signalStrategy_.getState() == |
| 114 remoting.SignalStrategy.State.CONNECTED); | 114 remoting.SignalStrategy.State.CONNECTED); |
| 115 this.signalStrategy_.setIncomingStanzaCallback( | 115 this.signalStrategy_.setIncomingStanzaCallback( |
| 116 this.onIncomingMessage_.bind(this)); | 116 this.onIncomingMessage_.bind(this)); |
| 117 remoting.formatIq.setJids(this.signalStrategy_.getJid(), hostJid); | 117 remoting.formatIq.setJids(this.signalStrategy_.getJid(), hostJid); |
| 118 | 118 |
| 119 /** @type {number?} @private */ | 119 /** @type {number?} @private */ |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 this.video_.style.height = '0px'; | 521 this.video_.style.height = '0px'; |
| 522 | 522 |
| 523 var renderer = new remoting.MediaSourceRenderer(this.video_); | 523 var renderer = new remoting.MediaSourceRenderer(this.video_); |
| 524 this.plugin_.enableMediaSourceRendering(renderer); | 524 this.plugin_.enableMediaSourceRendering(renderer); |
| 525 this.container_.classList.add('mediasource-rendering'); | 525 this.container_.classList.add('mediasource-rendering'); |
| 526 } else { | 526 } else { |
| 527 this.container_.classList.remove('mediasource-rendering'); | 527 this.container_.classList.remove('mediasource-rendering'); |
| 528 } | 528 } |
| 529 | 529 |
| 530 this.plugin_.setOnOutgoingIqHandler(this.sendIq_.bind(this)); | 530 this.plugin_.setOnOutgoingIqHandler(this.sendIq_.bind(this)); |
| 531 this.plugin_.setOnDebugMessageHandler( | 531 this.plugin_.setOnDebugMessageHandler(this.onDebugMessage_.bind(this)); |
| 532 /** @param {string} msg */ | |
| 533 function(msg) { | |
| 534 console.log('plugin: ' + msg.trimRight()); | |
| 535 }); | |
| 536 | 532 |
| 537 this.plugin_.setConnectionStatusUpdateHandler( | 533 this.plugin_.setConnectionStatusUpdateHandler( |
| 538 this.onConnectionStatusUpdate_.bind(this)); | 534 this.onConnectionStatusUpdate_.bind(this)); |
| 539 this.plugin_.setConnectionReadyHandler(this.onConnectionReady_.bind(this)); | 535 this.plugin_.setConnectionReadyHandler(this.onConnectionReady_.bind(this)); |
| 540 this.plugin_.setDesktopSizeUpdateHandler( | 536 this.plugin_.setDesktopSizeUpdateHandler( |
| 541 this.onDesktopSizeChanged_.bind(this)); | 537 this.onDesktopSizeChanged_.bind(this)); |
| 542 this.plugin_.setCapabilitiesHandler(this.onSetCapabilities_.bind(this)); | 538 this.plugin_.setCapabilitiesHandler(this.onSetCapabilities_.bind(this)); |
| 543 this.plugin_.setGnubbyAuthHandler( | 539 this.plugin_.setGnubbyAuthHandler( |
| 544 this.processGnubbyAuthMessage_.bind(this)); | 540 this.processGnubbyAuthMessage_.bind(this)); |
| 545 this.plugin_.setMouseCursorHandler(this.updateMouseCursorImage_.bind(this)); | 541 this.plugin_.setMouseCursorHandler(this.updateMouseCursorImage_.bind(this)); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 * remoting.Error.NONE if there is no error. | 594 * remoting.Error.NONE if there is no error. |
| 599 * @return {void} Nothing. | 595 * @return {void} Nothing. |
| 600 */ | 596 */ |
| 601 remoting.ClientSession.prototype.disconnect = function(error) { | 597 remoting.ClientSession.prototype.disconnect = function(error) { |
| 602 var state = (error == remoting.Error.NONE) ? | 598 var state = (error == remoting.Error.NONE) ? |
| 603 remoting.ClientSession.State.CLOSED : | 599 remoting.ClientSession.State.CLOSED : |
| 604 remoting.ClientSession.State.FAILED; | 600 remoting.ClientSession.State.FAILED; |
| 605 | 601 |
| 606 // The plugin won't send a state change notification, so we explicitly log | 602 // The plugin won't send a state change notification, so we explicitly log |
| 607 // the fact that the connection has closed. | 603 // the fact that the connection has closed. |
| 608 this.logToServer.logClientSessionStateChange(state, error, this.mode_); | 604 this.logToServer.logClientSessionStateChange(state, error); |
| 609 this.error_ = error; | 605 this.error_ = error; |
| 610 this.setState_(state); | 606 this.setState_(state); |
| 611 }; | 607 }; |
| 612 | 608 |
| 613 /** | 609 /** |
| 614 * Deletes the <embed> element from the container and disconnects. | 610 * Deletes the <embed> element from the container and disconnects. |
| 615 * | 611 * |
| 616 * @return {void} Nothing. | 612 * @return {void} Nothing. |
| 617 */ | 613 */ |
| 618 remoting.ClientSession.prototype.cleanup = function() { | 614 remoting.ClientSession.prototype.cleanup = function() { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 remoting.SignalStrategy.State.CONNECTED) { | 827 remoting.SignalStrategy.State.CONNECTED) { |
| 832 console.log("Message above is dropped because signaling is not connected."); | 828 console.log("Message above is dropped because signaling is not connected."); |
| 833 return; | 829 return; |
| 834 } | 830 } |
| 835 | 831 |
| 836 this.signalStrategy_.sendMessage(message); | 832 this.signalStrategy_.sendMessage(message); |
| 837 }; | 833 }; |
| 838 | 834 |
| 839 /** | 835 /** |
| 840 * @private | 836 * @private |
| 837 * @param {string} msg |
| 838 */ |
| 839 remoting.ClientSession.prototype.onDebugMessage_ = function(msg) { |
| 840 var isConnectionTypeMessage = msg.match( |
| 841 /^Channel (.*) using (.*) connection.$/); |
| 842 if (isConnectionTypeMessage) { |
| 843 this.logToServer.setConnectionType(isConnectionTypeMessage[2]); |
| 844 } |
| 845 console.log('plugin: ' + msg.trimRight()); |
| 846 }; |
| 847 |
| 848 /** |
| 849 * @private |
| 841 * @param {Element} message | 850 * @param {Element} message |
| 842 */ | 851 */ |
| 843 remoting.ClientSession.prototype.onIncomingMessage_ = function(message) { | 852 remoting.ClientSession.prototype.onIncomingMessage_ = function(message) { |
| 844 if (!this.plugin_) { | 853 if (!this.plugin_) { |
| 845 return; | 854 return; |
| 846 } | 855 } |
| 847 var formatted = new XMLSerializer().serializeToString(message); | 856 var formatted = new XMLSerializer().serializeToString(message); |
| 848 console.log(remoting.timestamp(), | 857 console.log(remoting.timestamp(), |
| 849 remoting.formatIq.prettifyReceiveIq(formatted)); | 858 remoting.formatIq.prettifyReceiveIq(formatted)); |
| 850 this.plugin_.onIncomingIq(formatted); | 859 this.plugin_.onIncomingIq(formatted); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 !this.logHostOfflineErrors_) { | 1037 !this.logHostOfflineErrors_) { |
| 1029 // The application requested host-offline errors to be suppressed, for | 1038 // The application requested host-offline errors to be suppressed, for |
| 1030 // example, because this connection attempt is using a cached host JID. | 1039 // example, because this connection attempt is using a cached host JID. |
| 1031 console.log('Suppressing host-offline error.'); | 1040 console.log('Suppressing host-offline error.'); |
| 1032 state = remoting.ClientSession.State.CONNECTION_CANCELED; | 1041 state = remoting.ClientSession.State.CONNECTION_CANCELED; |
| 1033 } | 1042 } |
| 1034 } else if (oldState == remoting.ClientSession.State.CONNECTED && | 1043 } else if (oldState == remoting.ClientSession.State.CONNECTED && |
| 1035 this.state_ == remoting.ClientSession.State.FAILED) { | 1044 this.state_ == remoting.ClientSession.State.FAILED) { |
| 1036 state = remoting.ClientSession.State.CONNECTION_DROPPED; | 1045 state = remoting.ClientSession.State.CONNECTION_DROPPED; |
| 1037 } | 1046 } |
| 1038 this.logToServer.logClientSessionStateChange(state, this.error_, this.mode_); | 1047 this.logToServer.logClientSessionStateChange(state, this.error_); |
| 1039 if (this.state_ == remoting.ClientSession.State.CONNECTED) { | 1048 if (this.state_ == remoting.ClientSession.State.CONNECTED) { |
| 1040 this.createGnubbyAuthHandler_(); | 1049 this.createGnubbyAuthHandler_(); |
| 1041 this.createCastExtensionHandler_(); | 1050 this.createCastExtensionHandler_(); |
| 1042 } | 1051 } |
| 1043 | 1052 |
| 1044 this.raiseEvent(remoting.ClientSession.Events.stateChanged, | 1053 this.raiseEvent(remoting.ClientSession.Events.stateChanged, |
| 1045 new remoting.ClientSession.StateEvent(newState, oldState) | 1054 new remoting.ClientSession.StateEvent(newState, oldState) |
| 1046 ); | 1055 ); |
| 1047 }; | 1056 }; |
| 1048 | 1057 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 remoting.ClientSession.prototype.getPerfStats = function() { | 1228 remoting.ClientSession.prototype.getPerfStats = function() { |
| 1220 return this.plugin_.getPerfStats(); | 1229 return this.plugin_.getPerfStats(); |
| 1221 }; | 1230 }; |
| 1222 | 1231 |
| 1223 /** | 1232 /** |
| 1224 * Logs statistics. | 1233 * Logs statistics. |
| 1225 * | 1234 * |
| 1226 * @param {remoting.ClientSession.PerfStats} stats | 1235 * @param {remoting.ClientSession.PerfStats} stats |
| 1227 */ | 1236 */ |
| 1228 remoting.ClientSession.prototype.logStatistics = function(stats) { | 1237 remoting.ClientSession.prototype.logStatistics = function(stats) { |
| 1229 this.logToServer.logStatistics(stats, this.mode_); | 1238 this.logToServer.logStatistics(stats); |
| 1230 }; | 1239 }; |
| 1231 | 1240 |
| 1232 /** | 1241 /** |
| 1233 * Enable or disable logging of connection errors due to a host being offline. | 1242 * Enable or disable logging of connection errors due to a host being offline. |
| 1234 * For example, if attempting a connection using a cached JID, host-offline | 1243 * For example, if attempting a connection using a cached JID, host-offline |
| 1235 * errors should not be logged because the JID will be refreshed and the | 1244 * errors should not be logged because the JID will be refreshed and the |
| 1236 * connection retried. | 1245 * connection retried. |
| 1237 * | 1246 * |
| 1238 * @param {boolean} enable True to log host-offline errors; false to suppress. | 1247 * @param {boolean} enable True to log host-offline errors; false to suppress. |
| 1239 */ | 1248 */ |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 * @param {string} data Contents of the extension message. | 1574 * @param {string} data Contents of the extension message. |
| 1566 * @return {boolean} True if the message was recognized, false otherwise. | 1575 * @return {boolean} True if the message was recognized, false otherwise. |
| 1567 */ | 1576 */ |
| 1568 remoting.ClientSession.prototype.handleExtensionMessage = | 1577 remoting.ClientSession.prototype.handleExtensionMessage = |
| 1569 function(type, data) { | 1578 function(type, data) { |
| 1570 if (this.videoFrameRecorder_) { | 1579 if (this.videoFrameRecorder_) { |
| 1571 return this.videoFrameRecorder_.handleMessage(type, data); | 1580 return this.videoFrameRecorder_.handleMessage(type, data); |
| 1572 } | 1581 } |
| 1573 return false; | 1582 return false; |
| 1574 } | 1583 } |
| OLD | NEW |