Browse Source

Added 100ms delay while sending chat messages.

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

34
static/js/directives/chat.js

@ -172,24 +172,28 @@ 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.
mediaStream.api.apply("sendChat", { _.delay(function() {
send: function(type, data) { mediaStream.api.apply("sendChat", {
// We also send to self, to display our own stuff. send: function(type, data) {
if (!noloop) { // We also send to self, to display our own stuff.
mediaStream.api.received({Type: data.Type, Data: data, From: mediaStream.api.id, To: peercall.id}); if (!noloop) {
mediaStream.api.received({Type: data.Type, Data: data, From: mediaStream.api.id, To: peercall.id});
}
return peercall.peerconnection.send(data);
} }
return peercall.peerconnection.send(data); })(to, message, status, mid);
} }, 100);
})(to, message, status, mid);
} else { } else {
subscope.p2p(false); subscope.p2p(false);
mediaStream.api.send2("sendChat", function(type, data) { _.delay(function() {
if (!noloop) { mediaStream.api.send2("sendChat", function(type, data) {
//console.log("looped to self", type, data); if (!noloop) {
mediaStream.api.received({Type: data.Type, Data: data, From: mediaStream.api.id, To: to}); //console.log("looped to self", type, data);
} 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;
}; };
@ -325,7 +329,7 @@ define(['underscore', 'text!partials/chat.html', 'text!partials/chatroom.html'],
scope.hideRoom(group_chat_id); scope.hideRoom(group_chat_id);
} }
}); });
}; };
}; };

Loading…
Cancel
Save