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. 21
      doc/CHANNELING-API.txt
  2. 13
      static/js/mediastream/peerxfer.js
  3. 11
      static/js/services/filedownload.js
  4. 4
      static/js/services/fileupload.js

21
doc/CHANNELING-API.txt

@ -681,11 +681,22 @@ File sharing data channel protocol @@ -681,11 +681,22 @@ File sharing data channel protocol
m is the mode. Currently only "r" is known to request chunks.
i is the chunk sequence number to request (integer).
Whenever you want the peer to send a chunk, request it by sending a
JSON chunk request over the data channel with the sequence which
should be transmitted. The current web implementation requests chunks
sequentially, and waiting for each chunk to be complete before
sending the request for the next one.
Whenever you want the peer to send a chunk, request it by sending a
JSON chunk request over the data channel with the sequence which
should be transmitted. The current web implementation requests chunks
sequentially, and waiting for each chunk to be complete before
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.

13
static/js/mediastream/peerxfer.js

@ -48,8 +48,8 @@ define(['jquery', 'underscore', 'mediastream/peercall', 'mediastream/tokens', 'w @@ -48,8 +48,8 @@ define(['jquery', 'underscore', 'mediastream/peercall', 'mediastream/tokens', 'w
};
this.sdpConstraints = {};
// SCTP is supported from Chrome M31.
// No need to pass DTLS constraint as it is on by default in Chrome M31.
// For SCTP, reliable and ordered is true by default.
// No need to pass DTLS constraint as it is on by default in Chrome M31.
// For SCTP, reliable and ordered is true by default.
this.pcConstraints = {};
// Inject token into sessiondescription and ice candidate data.
@ -58,13 +58,6 @@ define(['jquery', 'underscore', 'mediastream/peercall', 'mediastream/tokens', 'w @@ -58,13 +58,6 @@ define(['jquery', 'underscore', 'mediastream/peercall', 'mediastream/tokens', 'w
data._id = this.id;
}, 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.
@ -78,7 +71,7 @@ define(['jquery', 'underscore', 'mediastream/peercall', 'mediastream/tokens', 'w @@ -78,7 +71,7 @@ define(['jquery', 'underscore', 'mediastream/peercall', 'mediastream/tokens', 'w
PeerXfer.prototype.cancel = function() {
this.e.triggerHandler("cancel", [this]);
this.close();
}
};
PeerXfer.prototype.onMessage = function(event) {
// Our own datachannel event.

11
static/js/services/filedownload.js

@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
*/
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;
@ -57,9 +57,14 @@ define(["jquery", "underscore"], function($, _) { @@ -57,9 +57,14 @@ define(["jquery", "underscore"], function($, _) {
$window.clearInterval(this.interval);
this.interval = null;
// close all known xfers.
// Close all known xfers.
_.each(this.xfer_all, function(xfer) {
xfer.cancel();
// 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();
}, 0);
});
_.each(this.jobs, function(job) {
job.stop = true;

4
static/js/services/fileupload.js

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

Loading…
Cancel
Save