Skip to content

Commit

Permalink
browser updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Contra committed Mar 5, 2013
1 parent 66f9ca2 commit c1bca65
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 135 deletions.
7 changes: 5 additions & 2 deletions dist/Call.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/holla.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions dist/shims.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 43 additions & 59 deletions examples/holla.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ var err = { type: 'error', data: 'parser error' }
*/

exports.encodePacket = function (packet) {
var encoded = packets[packet.type];
var encoded = packets[packet.type]

// data fragment is optional
if (undefined !== packet.data) {
Expand Down Expand Up @@ -314,61 +314,62 @@ exports.encodePayload = function (packets) {
/*
* Decodes data when a payload is maybe expected.
*
* @param {String} data, callback method
* @return {NaN}
* @param {String} data
* @return {Array} packets
* @api public
*/

exports.decodePayload = function (data, callback) {
var packet;
exports.decodePayload = function (data) {
if (data == '') {
// parser error - ignoring payload
return callback(err, 0, 1);
return [err];
}

var length = ''
, n, msg;
var packets = []
, length = ''
, n, msg, packet

for (var i = 0, l = data.length; i < l; i++) {
var chr = data.charAt(i);
var chr = data.charAt(i)

if (':' != chr) {
length += chr;
} else {
if ('' == length || (length != (n = Number(length)))) {
// parser error - ignoring payload
return callback(err, 0, 1);
return [err];
}

msg = data.substr(i + 1, n);

if (length != msg.length) {
// parser error - ignoring payload
return callback(err, 0, 1);
return [err];
}

if (msg.length) {
packet = exports.decodePacket(msg);

if (err.type == packet.type && err.data == packet.data) {
// parser error in individual packet - ignoring payload
return callback(err, 0, 1);
return [err];
}

callback(packet, i + n, l);
packets.push(packet);
}

// advance cursor
i += n;
length = '';
length = ''
}
}

if (length != '') {
// parser error - ignoring payload
return callback(err, 0, 1);
return [err];
}

return packets;
};

});
Expand Down Expand Up @@ -1716,32 +1717,25 @@ Polling.prototype.poll = function(){
*/

Polling.prototype.onData = function(data){
var self = this;
debug('polling got data %s', data);
// decode payload
parser.decodePayload(data, function(packet, index, total) {self.onDataCallback(packet, index, total)});
};
var packets = parser.decodePayload(data);

/**
* Callback function for payloads
*
* @api private
*/

Polling.prototype.onDataCallback = function(packet, index, total){
// if its the first message we consider the transport open
if ('opening' == this.readyState) {
this.onOpen();
}
for (var i = 0, l = packets.length; i < l; i++) {
// if its the first message we consider the trnasport open
if ('opening' == this.readyState) {
this.onOpen();
}

// if its a close packet, we close the ongoing requests
if ('close' == packet.type) {
this.onClose();
return;
}
// if its a close packet, we close the ongoing requests
if ('close' == packets[i].type) {
this.onClose();
return;
}

// otherwise bypass onData and handle the message
this.onPacket(packet);
// otherwise bypass onData and handle the message
this.onPacket(packets[i]);
}

// if we got data we're not polling
this.polling = false;
Expand Down Expand Up @@ -2299,11 +2293,7 @@ JSONPPolling.prototype.doWrite = function (data, fn) {

function initIframe () {
if (self.iframe) {
try {
self.form.removeChild(self.iframe);
} catch (e) {
self.onError('jsonp polling iframe removal error', e);
}
self.form.removeChild(self.iframe);
}

try {
Expand Down Expand Up @@ -3215,14 +3205,6 @@ Emitter.prototype.off =
Emitter.prototype.removeListener =
Emitter.prototype.removeAllListeners = function(event, fn){
this._callbacks = this._callbacks || {};

// all
if (0 == arguments.length) {
this._callbacks = {};
return this;
}

// specific event
var callbacks = this._callbacks[event];
if (!callbacks) return this;

Expand Down Expand Up @@ -3288,7 +3270,7 @@ Emitter.prototype.hasListeners = function(event){

});
require.register("holla/dist/holla.js", function(exports, require, module){
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.1
(function() {
var Call, ProtoSock, client, holla, shims;

Expand Down Expand Up @@ -3525,7 +3507,7 @@ require.register("holla/dist/holla.js", function(exports, require, module){

});
require.register("holla/dist/Call.js", function(exports, require, module){
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.1
(function() {
var Call, EventEmitter, shims,
__hasProp = {}.hasOwnProperty,
Expand Down Expand Up @@ -3567,6 +3549,10 @@ require.register("holla/dist/Call.js", function(exports, require, module){
this.parent.on("sdp." + this.user, function(desc) {
desc.sdp = shims.processSDPIn(desc.sdp);
_this.pc.setRemoteDescription(new shims.SessionDescription(desc));
console.log(desc);
if (!_this.isCaller) {
_this.initSDP();
}
return _this.emit("sdp");
});
this.parent.on("hangup." + this.user, function() {
Expand Down Expand Up @@ -3649,7 +3635,6 @@ require.register("holla/dist/Call.js", function(exports, require, module){
accepted: true
}
});
this.initSDP();
return this;
};

Expand Down Expand Up @@ -3713,7 +3698,7 @@ require.register("holla/dist/Call.js", function(exports, require, module){

});
require.register("holla/dist/shims.js", function(exports, require, module){
// Generated by CoffeeScript 1.4.0
// Generated by CoffeeScript 1.6.1
(function() {
var IceCandidate, MediaStream, PeerConnection, SessionDescription, URL, attachStream, browser, extract, getUserMedia, loadBlob, processSDPIn, processSDPOut, recordVideo, removeCN, replaceCodec, saveBlob, shim, supported, useOPUS;

Expand Down Expand Up @@ -3961,11 +3946,11 @@ require.register("holla/dist/shims.js", function(exports, require, module){
]
};
mediaConstraints = {
mandatory: {
OfferToReceiveAudio: true,
OfferToReceiveVideo: true,
DtlsSrtpKeyAgreement: true
}
optional: [
{
DtlsSrtpKeyAgreement: true
}
]
};
if (!MediaStream.prototype.getVideoTracks) {
MediaStream.prototype.getVideoTracks = function() {
Expand Down Expand Up @@ -4040,7 +4025,6 @@ this.duration)throw"you can't pass a duration if the fps is set";if("undefined"=
this.frames.push({image:a,duration:b||this.duration})};i.prototype.compile=function(){return new g(this.frames.map(function(a){var b=l(h(atob(a.image.slice(23))));b.duration=a.duration;return b}))};return{Video:i,fromImageArray:function(a,b){return g(a.map(function(a){a=l(h(atob(a.slice(23))));a.duration=1E3/b;return a}))},toWebM:g}}();
;


module.exports = shim();

}).call(this);
Expand Down
Loading

0 comments on commit c1bca65

Please sign in to comment.