Skip to content

Commit

Permalink
Delete DOM nodes in forever frame in JS client after every 50th recei…
Browse files Browse the repository at this point in the history
…ved message.

Fixes #458
  • Loading branch information
DamianEdwards committed Jun 19, 2012
1 parent dcabd78 commit 301d603
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 123 deletions.
229 changes: 116 additions & 113 deletions SignalR.sln

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion SignalR/Scripts/jquery.signalR.js
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion SignalR/Scripts/jquery.signalR.min.js

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions SignalR/Transports/ForeverFrameTransport.cs
Expand Up @@ -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" +
Expand All @@ -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;

Expand Down
14 changes: 13 additions & 1 deletion samples/SignalR.Hosting.AspNet.Samples/Scripts/jquery.signalR.js
Expand Up @@ -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;
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -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;
Expand Down

Large diffs are not rendered by default.

0 comments on commit 301d603

Please sign in to comment.