summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-21 04:48:40 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-21 04:48:40 +0000
commit51f27b3c93ca7c281a43427ed57ddd1e609e94fc (patch)
tree39cb6163569aeb09543ecbff70f94272fefbbc4e
parentd227c0b90e8c01eb43b774304be00cf1a82057cc (diff)
downloadchromium_src-51f27b3c93ca7c281a43427ed57ddd1e609e94fc.zip
chromium_src-51f27b3c93ca7c281a43427ed57ddd1e609e94fc.tar.gz
chromium_src-51f27b3c93ca7c281a43427ed57ddd1e609e94fc.tar.bz2
Add hack that works around signaling bug that breaks Chromoting.
Signaling endpoint used by chromoting doesn't always handle correctly the case when host and client use the same stanza ID's. Workaround this issue by adding 'x' prefix to all messages that go from client to host. This is the same change as in crrev.com/160330 . That CL was reverted because it was believed that the original bug was fixed. BUG=168617 Review URL: https://chromiumcodereview.appspot.com/11926031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177892 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/webapp/client_session.js28
1 files changed, 27 insertions, 1 deletions
diff --git a/remoting/webapp/client_session.js b/remoting/webapp/client_session.js
index 3dfaa43..1cf5e13 100644
--- a/remoting/webapp/client_session.js
+++ b/remoting/webapp/client_session.js
@@ -524,7 +524,6 @@ remoting.ClientSession.prototype.hasReceivedFrame = function() {
* @return {void} Nothing.
*/
remoting.ClientSession.prototype.sendIq_ = function(msg) {
- console.log(remoting.timestamp(), remoting.formatIq.prettifySendIq(msg));
// Extract the session id, so we can close the session later.
var parser = new DOMParser();
var iqNode = parser.parseFromString(msg, 'text/xml').firstChild;
@@ -536,6 +535,19 @@ remoting.ClientSession.prototype.sendIq_ = function(msg) {
}
}
+ // HACK: Add 'x' prefix to the IDs of the outgoing messages to make sure that
+ // stanza IDs used by host and client do not match. This is necessary to
+ // workaround bug in the signaling endpoint used by chromoting.
+ // TODO(sergeyu): Remove this hack once the server-side bug is fixed.
+ var type = iqNode.getAttribute('type');
+ if (type == 'set') {
+ var id = iqNode.getAttribute('id');
+ iqNode.setAttribute('id', 'x' + id);
+ msg = (new XMLSerializer()).serializeToString(iqNode);
+ }
+
+ console.log(remoting.timestamp(), remoting.formatIq.prettifySendIq(msg));
+
// Send the stanza.
if (remoting.wcs) {
remoting.wcs.sendIq(msg);
@@ -561,6 +573,20 @@ remoting.ClientSession.prototype.connectPluginToWcs_ = function() {
var forwardIq = plugin.onIncomingIq.bind(plugin);
/** @param {string} stanza The IQ stanza received. */
var onIncomingIq = function(stanza) {
+ // HACK: Remove 'x' prefix added to the id in sendIq_().
+ try {
+ var parser = new DOMParser();
+ var iqNode = parser.parseFromString(stanza, 'text/xml').firstChild;
+ var type = iqNode.getAttribute('type');
+ var id = iqNode.getAttribute('id');
+ if (type != 'set' && id.charAt(0) == 'x') {
+ iqNode.setAttribute('id', id.substr(1));
+ stanza = (new XMLSerializer()).serializeToString(iqNode);
+ }
+ } catch (err) {
+ // Pass message as is when it is malformed.
+ }
+
console.log(remoting.timestamp(),
remoting.formatIq.prettifyReceiveIq(stanza));
forwardIq(stanza);