delayed connected was not working for socket candidates

This commit is contained in:
Michelle Bu 2013-02-03 10:58:32 -08:00
parent 0d264b4119
commit d998280445

View File

@ -113,16 +113,19 @@ PeerServer.prototype._initializeWSS = function() {
/** Process outstanding peer offers. */ /** Process outstanding peer offers. */
PeerServer.prototype._processOutstandingOffers = function(id) { PeerServer.prototype._processOutstandingOffers = function(id) {
console.log('processing outstanding offers');
var offers = this._outstandingOffers[id]; var offers = this._outstandingOffers[id];
for (var source in offers) { if (offers === undefined)
if (offers.hasOwnProperty(source)) { return;
var messages = offers[source] var sources = Object.keys(offers);
for (var i = 0; i < messages.length; i += 1) for (var i = 0, ii = sources.length; i < ii; i += 1) {
this._handleTransmission.apply(this, messages[i]); var messages = offers[sources[i]];
for (var j = 0, jj = messages.length; j < jj; j += 1)
this._handleTransmission.apply(this, messages[j]);
delete this._outstandingOffers[id][source]; delete this._outstandingOffers[id][sources[i]];
}
} }
console.log(this._outstandingOffers[id]);
}; };
/** Initialize HTTP server routes. */ /** Initialize HTTP server routes. */
@ -160,7 +163,7 @@ PeerServer.prototype._initializeHTTP = function() {
this._app.post('/ice', function(req, res) { this._app.post('/ice', function(req, res) {
var src = req.body.src; var src = req.body.src;
var dst = req.body.dst; var dst = req.body.dst;
self._handleTransmission('ICE', src, dst, JSON.stringify(req.body), res); self._handleTransmission('CANDIDATE', src, dst, JSON.stringify(req.body), res);
}); });
this._app.post('/answer', function(req, res) { this._app.post('/answer', function(req, res) {
@ -242,11 +245,13 @@ PeerServer.prototype._handleTransmission = function(type, src, dst, data, res) {
this._outstandingOffers[dst][src] = []; this._outstandingOffers[dst][src] = [];
this._outstandingOffers[dst][src].push(Array.prototype.slice.apply(arguments)); this._outstandingOffers[dst][src].push(Array.prototype.slice.apply(arguments));
console.log('offer on queue');
setTimeout(function() { setTimeout(function() {
delete self._outstandingOffers[dst][src] delete self._outstandingOffers[dst][src]
}, 5000); }, 30000);
} else if (type === 'ICE' && !!this._outstandingOffers[dst][src]) { } else if (type === 'CANDIDATE' && !!this._outstandingOffers[dst][src]) {
this._outstandingOffers[dst][src].push(Array.prototype.slice.apply(arguments)); this._outstandingOffers[dst][src].push(Array.prototype.slice.apply(arguments));
console.log('ice on queue');
} else { } else {
// Assume a disconnect if the client no longer exists. // Assume a disconnect if the client no longer exists.
util.log('destination does not exist'); util.log('destination does not exist');