Browse Source

Added 100ms delay while sending chat messages.

pull/4/head
Simon Eisenmann 12 years ago
parent
commit
2c500ead30
  1. 4
      static/js/directives/chat.js

4
static/js/directives/chat.js

@ -172,6 +172,7 @@ define(['underscore', 'text!partials/chat.html', 'text!partials/chatroom.html'],
if (peercall && peercall.peerconnection.datachannelReady) { if (peercall && peercall.peerconnection.datachannelReady) {
subscope.p2p(true); subscope.p2p(true);
// Send out stuff through data channel. // Send out stuff through data channel.
_.delay(function() {
mediaStream.api.apply("sendChat", { mediaStream.api.apply("sendChat", {
send: function(type, data) { send: function(type, data) {
// We also send to self, to display our own stuff. // We also send to self, to display our own stuff.
@ -181,15 +182,18 @@ define(['underscore', 'text!partials/chat.html', 'text!partials/chatroom.html'],
return peercall.peerconnection.send(data); return peercall.peerconnection.send(data);
} }
})(to, message, status, mid); })(to, message, status, mid);
}, 100);
} else { } else {
subscope.p2p(false); subscope.p2p(false);
_.delay(function() {
mediaStream.api.send2("sendChat", function(type, data) { mediaStream.api.send2("sendChat", function(type, data) {
if (!noloop) { if (!noloop) {
//console.log("looped to self", type, data); //console.log("looped to self", type, data);
mediaStream.api.received({Type: data.Type, Data: data, From: mediaStream.api.id, To: to}); mediaStream.api.received({Type: data.Type, Data: data, From: mediaStream.api.id, To: to});
} }
})(to, message, status, mid); })(to, message, status, mid);
}, 100);
} }
return mid; return mid;
}; };

Loading…
Cancel
Save