Browse Source

Limit chat message send size to 200000 characters to avoid hanging clients.

pull/183/head
Simon Eisenmann 11 years ago
parent
commit
d13e59c749
  1. 8
      static/js/directives/chat.js
  2. 2
      static/partials/chatroom.html

8
static/js/directives/chat.js

@ -26,6 +26,7 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
var displayName = safeDisplayName; var displayName = safeDisplayName;
var groupChatId = ""; var groupChatId = "";
var maxMessageSize = 200000;
var controller = ['$scope', '$element', '$attrs', function($scope, $element, $attrs) { var controller = ['$scope', '$element', '$attrs', function($scope, $element, $attrs) {
@ -42,6 +43,8 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
$scope.currentRoom = null; $scope.currentRoom = null;
$scope.currentRoomActive = false; $scope.currentRoomActive = false;
$scope.maxMessageSize = maxMessageSize;
$scope.getVisibleRooms = function() { $scope.getVisibleRooms = function() {
var res = []; var res = [];
for (var i = 0; i < ctrl.visibleRooms.length; i++) { for (var i = 0; i < ctrl.visibleRooms.length; i++) {
@ -245,6 +248,10 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
}; };
subscope.sendChat = function(to, message, status, mid, noloop) { subscope.sendChat = function(to, message, status, mid, noloop) {
//console.log("send chat", to, scope.peer); //console.log("send chat", to, scope.peer);
if (message && message.length > maxMessageSize) {
console.log("XXXXXXX", message.length);
return mid;
}
var peercall = mediaStream.webrtc.findTargetCall(to); var peercall = mediaStream.webrtc.findTargetCall(to);
if (peercall && peercall.peerconnection && peercall.peerconnection.datachannelReady) { if (peercall && peercall.peerconnection && peercall.peerconnection.datachannelReady) {
subscope.p2p(true); subscope.p2p(true);
@ -254,7 +261,6 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
subscope.p2p(false); subscope.p2p(false);
return subscope.sendChatServer(to, message, status, mid, noloop); return subscope.sendChatServer(to, message, status, mid, noloop);
} }
return mid;
}; };
subscope.sendChatPeer2Peer = function(peercall, to, message, status, mid, noloop) { subscope.sendChatPeer2Peer = function(peercall, to, message, status, mid, noloop) {
if (message && !mid) { if (message && !mid) {

2
static/partials/chatroom.html

@ -21,7 +21,7 @@
</div> </div>
<div class="inputbox"> <div class="inputbox">
<div> <div>
<textarea class="input nicescroll form-control" ng-disabled="!(enabled)" on-enter="submit()" ng-model="input" placeholder="{{_('Type here to chat...')}}"/> <textarea class="input nicescroll form-control" maxlength="{{maxMessageSize}}" ng-disabled="!(enabled)" on-enter="submit()" ng-model="input" placeholder="{{_('Type here to chat...')}}"/>
</div> </div>
<a ng-disabled="!(enabled)" ng-click="submit()" title="{{_('Send')}}" class="btn btn-small btn-info fa fa-play"></a> <a ng-disabled="!(enabled)" ng-click="submit()" title="{{_('Send')}}" class="btn btn-small btn-info fa fa-play"></a>
</div> </div>

Loading…
Cancel
Save