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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 /** @private */ | 50 /** @private */ |
51 this.hasReceivedFrame_ = false; | 51 this.hasReceivedFrame_ = false; |
52 this.logToServer = new remoting.LogToServer(signalStrategy); | 52 this.logToServer = new remoting.LogToServer(signalStrategy); |
53 | 53 |
54 /** @private */ | 54 /** @private */ |
55 this.signalStrategy_ = signalStrategy; | 55 this.signalStrategy_ = signalStrategy; |
56 base.debug.assert(this.signalStrategy_.getState() == | 56 base.debug.assert(this.signalStrategy_.getState() == |
57 remoting.SignalStrategy.State.CONNECTED); | 57 remoting.SignalStrategy.State.CONNECTED); |
58 this.signalStrategy_.setIncomingStanzaCallback( | 58 this.signalStrategy_.setIncomingStanzaCallback( |
59 this.onIncomingMessage_.bind(this)); | 59 this.onIncomingMessage_.bind(this)); |
60 remoting.formatIq.setJids(this.signalStrategy_.getJid(), host.jabberId); | 60 |
61 /** @private */ | |
62 this.iqFormatter_ = new remoting.FormatIq(); | |
kelvinp
2015/04/16 18:13:01
instead of the global remoting.formatIq
| |
63 this.iqFormatter_.setJids(this.signalStrategy_.getJid(), host.jabberId); | |
Jamie
2015/04/16 20:15:29
Move these to ctor parameters now that the object
| |
61 | 64 |
62 /** | 65 /** |
63 * Allow host-offline error reporting to be suppressed in situations where it | 66 * Allow host-offline error reporting to be suppressed in situations where it |
64 * would not be useful, for example, when using a cached host JID. | 67 * would not be useful, for example, when using a cached host JID. |
65 * | 68 * |
66 * @type {boolean} @private | 69 * @type {boolean} @private |
67 */ | 70 */ |
68 this.logHostOfflineErrors_ = true; | 71 this.logHostOfflineErrors_ = true; |
69 | 72 |
70 /** @private {remoting.ClientPlugin} */ | 73 /** @private {remoting.ClientPlugin} */ |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 var parser = new DOMParser(); | 362 var parser = new DOMParser(); |
360 var iqNode = parser.parseFromString(message, 'text/xml').firstChild; | 363 var iqNode = parser.parseFromString(message, 'text/xml').firstChild; |
361 var jingleNode = iqNode.firstChild; | 364 var jingleNode = iqNode.firstChild; |
362 if (jingleNode) { | 365 if (jingleNode) { |
363 var action = jingleNode.getAttribute('action'); | 366 var action = jingleNode.getAttribute('action'); |
364 if (jingleNode.nodeName == 'jingle' && action == 'session-initiate') { | 367 if (jingleNode.nodeName == 'jingle' && action == 'session-initiate') { |
365 this.sessionId_ = jingleNode.getAttribute('sid'); | 368 this.sessionId_ = jingleNode.getAttribute('sid'); |
366 } | 369 } |
367 } | 370 } |
368 | 371 |
369 console.log(remoting.timestamp(), remoting.formatIq.prettifySendIq(message)); | 372 console.log(base.timestamp(), this.iqFormatter_.prettifySendIq(message)); |
370 if (this.signalStrategy_.getState() != | 373 if (this.signalStrategy_.getState() != |
371 remoting.SignalStrategy.State.CONNECTED) { | 374 remoting.SignalStrategy.State.CONNECTED) { |
372 console.log("Message above is dropped because signaling is not connected."); | 375 console.log("Message above is dropped because signaling is not connected."); |
373 return; | 376 return; |
374 } | 377 } |
375 | 378 |
376 this.signalStrategy_.sendMessage(message); | 379 this.signalStrategy_.sendMessage(message); |
377 }; | 380 }; |
378 | 381 |
379 /** | 382 /** |
(...skipping 12 matching lines...) Expand all Loading... | |
392 | 395 |
393 /** | 396 /** |
394 * @param {Element} message | 397 * @param {Element} message |
395 * @private | 398 * @private |
396 */ | 399 */ |
397 remoting.ClientSession.prototype.onIncomingMessage_ = function(message) { | 400 remoting.ClientSession.prototype.onIncomingMessage_ = function(message) { |
398 if (!this.plugin_) { | 401 if (!this.plugin_) { |
399 return; | 402 return; |
400 } | 403 } |
401 var formatted = new XMLSerializer().serializeToString(message); | 404 var formatted = new XMLSerializer().serializeToString(message); |
402 console.log(remoting.timestamp(), | 405 console.log(base.timestamp(), this.iqFormatter_.prettifyReceiveIq(formatted)); |
Jamie
2015/04/16 20:15:29
Unrelated to your change, but can this be restruct
kelvinp
2015/04/16 21:18:37
Done.
| |
403 remoting.formatIq.prettifyReceiveIq(formatted)); | |
404 this.plugin_.onIncomingIq(formatted); | 406 this.plugin_.onIncomingIq(formatted); |
405 }; | 407 }; |
406 | 408 |
407 /** | 409 /** |
408 * Callback that the plugin invokes to indicate that the connection | 410 * Callback that the plugin invokes to indicate that the connection |
409 * status has changed. | 411 * status has changed. |
410 * | 412 * |
411 * @param {remoting.ClientSession.State} status The plugin's status. | 413 * @param {remoting.ClientSession.State} status The plugin's status. |
412 * @param {remoting.ClientSession.ConnectionError} error The plugin's error | 414 * @param {remoting.ClientSession.ConnectionError} error The plugin's error |
413 * state, if any. | 415 * state, if any. |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
564 * For example, if attempting a connection using a cached JID, host-offline | 566 * For example, if attempting a connection using a cached JID, host-offline |
565 * errors should not be logged because the JID will be refreshed and the | 567 * errors should not be logged because the JID will be refreshed and the |
566 * connection retried. | 568 * connection retried. |
567 * | 569 * |
568 * @param {boolean} enable True to log host-offline errors; false to suppress. | 570 * @param {boolean} enable True to log host-offline errors; false to suppress. |
569 */ | 571 */ |
570 remoting.ClientSession.prototype.logHostOfflineErrors = function(enable) { | 572 remoting.ClientSession.prototype.logHostOfflineErrors = function(enable) { |
571 this.logHostOfflineErrors_ = enable; | 573 this.logHostOfflineErrors_ = enable; |
572 }; | 574 }; |
573 | 575 |
OLD | NEW |