Permalink
Browse files

Delete DOM nodes in forever frame in JS client after every 50th recei…

…ved message.

Fixes #458
  • Loading branch information...
1 parent dcabd78 commit 301d6037c4bb24ab2fb154416fb693c0dc7bc794 @DamianEdwards DamianEdwards committed Jun 19, 2012
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -933,7 +933,19 @@
transportLogic.ajaxSend(connection, data);
},
- receive: transportLogic.processMessages,
+ receive: function (connection, data) {
+ var cw;
+ transportLogic.processMessages(connection, data);
+ // Delete the script & div elements
+ connection.frameMessageCount = (connection.frameMessageCount || 0) + 1;
+ if (connection.frameMessageCount > 50) {
+ connection.frameMessageCount = 0;
+ cw = connection.frame.contentWindow || connection.frame.contentDocument;
+ if (cw && cw.document) {
+ $("body", cw.document).empty();
+ }
+ }
+ },
stop: function (connection) {
var cw = null;

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -6,9 +6,10 @@ namespace SignalR.Transports
{
public class ForeverFrameTransport : ForeverTransport
{
- private const string _initPrefix = "<!DOCTYPE html><html><head>" +
- "<title>SignalR Forever Frame Transport Stream</title></head>\r\n" +
- "<body>\r\n" +
+ private const string _initPrefix = "<!DOCTYPE html>" +
+ "<html>" +
+ "<head>" +
+ "<title>SignalR Forever Frame Transport Stream</title>\r\n" +
"<script>\r\n" + //" debugger;\r\n"+
" var $ = window.parent.jQuery,\r\n" +
" ff = $ ? $.signalR.transports.foreverFrame : null,\r\n" +
@@ -17,7 +18,8 @@ public class ForeverFrameTransport : ForeverTransport
private const string _initSuffix = "') : null,\r\n" +
" r = ff ? ff.receive : function() {};\r\n" +
" ff ? ff.started(c) : '';" +
- "</script>";
+ "</script></head>" +
+ "<body>\r\n";
private readonly bool _isDebug;
@@ -933,7 +933,19 @@
transportLogic.ajaxSend(connection, data);
},
- receive: transportLogic.processMessages,
+ receive: function (connection, data) {
+ var cw;
+ transportLogic.processMessages(connection, data);
+ // Delete the script & div elements
+ connection.frameMessageCount = (connection.frameMessageCount || 0) + 1;
+ if (connection.frameMessageCount > 50) {
+ connection.frameMessageCount = 0;
+ cw = connection.frame.contentWindow || connection.frame.contentDocument;
+ if (cw && cw.document) {
+ $("body", cw.document).empty();
+ }
+ }
+ },
stop: function (connection) {
var cw = null;

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -933,7 +933,19 @@
transportLogic.ajaxSend(connection, data);
},
- receive: transportLogic.processMessages,
+ receive: function (connection, data) {
+ var cw;
+ transportLogic.processMessages(connection, data);
+ // Delete the script & div elements
+ connection.frameMessageCount = (connection.frameMessageCount || 0) + 1;
+ if (connection.frameMessageCount > 50) {
+ connection.frameMessageCount = 0;
+ cw = connection.frame.contentWindow || connection.frame.contentDocument;
+ if (cw && cw.document) {
+ $("body", cw.document).empty();
+ }
+ }
+ },
stop: function (connection) {
var cw = null;

Large diffs are not rendered by default.

Oops, something went wrong.

0 comments on commit 301d603

Please sign in to comment.