Browse Source

No longer close xfer connections on ice state disconnected and instead sed bye message when downloader does no longer require a connection.

pull/3/head
Simon Eisenmann 12 years ago
parent
commit
ba1969e850
  1. 11
      doc/CHANNELING-API.txt
  2. 9
      static/js/mediastream/peerxfer.js
  3. 9
      static/js/services/filedownload.js
  4. 4
      static/js/services/fileupload.js

11
doc/CHANNELING-API.txt

@ -687,6 +687,17 @@ File sharing data channel protocol
sequentially, and waiting for each chunk to be complete before sequentially, and waiting for each chunk to be complete before
sending the request for the next one. sending the request for the next one.
JSON bye request
{
"m": "bye"
}
This is used to clean up connections when the downloader is finished
or has manually aborted downloading. The downloader sends this message
to the connected peer which then may close the connection where this
message was received.
End of Channeling API. End of Channeling API.

9
static/js/mediastream/peerxfer.js

@ -58,13 +58,6 @@ define(['jquery', 'underscore', 'mediastream/peercall', 'mediastream/tokens', 'w
data._id = this.id; data._id = this.id;
}, this)); }, this));
this.e.on("connectionStateChange", _.bind(function(event, iceConnectionState) {
if (iceConnectionState === "disconnected") {
// Auto cleanup stuff when we get disconnected.
this.close();
}
}, this));
}; };
// Inherit from PeerCall. // Inherit from PeerCall.
@ -78,7 +71,7 @@ define(['jquery', 'underscore', 'mediastream/peercall', 'mediastream/tokens', 'w
PeerXfer.prototype.cancel = function() { PeerXfer.prototype.cancel = function() {
this.e.triggerHandler("cancel", [this]); this.e.triggerHandler("cancel", [this]);
this.close(); this.close();
} };
PeerXfer.prototype.onMessage = function(event) { PeerXfer.prototype.onMessage = function(event) {
// Our own datachannel event. // Our own datachannel event.

9
static/js/services/filedownload.js

@ -20,7 +20,7 @@
*/ */
define(["jquery", "underscore"], function($, _) { define(["jquery", "underscore"], function($, _) {
return ["fileData", "fileTransfer", "$window", "mediaStream", "safeApply", function(fileData, fileTransfer, $window, mediaStream, safeApply) { return ["fileData", "fileTransfer", "$window", "mediaStream", "safeApply", "$timeout", function(fileData, fileTransfer, $window, mediaStream, safeApply, $timeout) {
var downloads = 0; var downloads = 0;
@ -57,9 +57,14 @@ define(["jquery", "underscore"], function($, _) {
$window.clearInterval(this.interval); $window.clearInterval(this.interval);
this.interval = null; this.interval = null;
// close all known xfers. // Close all known xfers.
_.each(this.xfer_all, function(xfer) { _.each(this.xfer_all, function(xfer) {
// Implement own clean up message.
// NOTE(longsleep): See https://code.google.com/p/webrtc/issues/detail?id=1676 for reason.
xfer.send({m: "bye"});
$timeout(function() {
xfer.cancel(); xfer.cancel();
}, 0);
}); });
_.each(this.jobs, function(job) { _.each(this.jobs, function(job) {
job.stop = true; job.stop = true;

4
static/js/services/fileupload.js

@ -112,6 +112,10 @@ define(["jquery", "underscore", "webrtc.adapter"], function($, _) {
}); });
}, this)); }, this));
break; break;
case "bye":
// Close this xfer.
xfer.cancel();
break;
default: default:
console.log("Unknown xfer control request", msg.m, msg); console.log("Unknown xfer control request", msg.m, msg);
break; break;

Loading…
Cancel
Save