Skip to content
Browse files

cleanup broken streams

  • Loading branch information...
1 parent 5b3f72d commit 04b5d65f7eba96c77e9d809ec05e76595944cccb @WardCunningham committed Dec 28, 2012
View
2 client/plugins/logwatch/logwatch.coffee
@@ -11,7 +11,7 @@ window.plugins.logwatch =
socket.onmessage = (e) ->
msg = JSON.parse e.data
- print wiki.resolveLinks("[[#{msg.title}]]")
+ print wiki.resolveLinks("[[#{msg.title}]] #{msg.listeners}")
socket.onclose = ->
print "WebSocket Connection Closed."
View
2 client/plugins/logwatch/logwatch.js
@@ -15,7 +15,7 @@
socket.onmessage = function(e) {
var msg;
msg = JSON.parse(e.data);
- return print(wiki.resolveLinks("[[" + msg.title + "]]"));
+ return print(wiki.resolveLinks("[[" + msg.title + "]] " + msg.listeners));
};
return socket.onclose = function() {
return print("WebSocket Connection Closed.");
View
6 server/express/lib/server.coffee
@@ -101,13 +101,15 @@ module.exports = exports = (argv) ->
)
)
logWatchSocket.on('connection', (ws) ->
- logWatchSocket.on('fetch', (page) ->
+ logWatchSocket.on('fetch', fetchListener = (page) ->
reference =
title: page.title
+ listeners: logWatchSocket.listeners('fetch').length
ws.send JSON.stringify(reference), (e) ->
if e
log 'unable to send ws message: ', e
- return
+ logWatchSocket.removeListener 'fetch', fetchListener
+ ws.close()
)
ws.on('message', (message) ->
log 'logWatch message from client:', message

0 comments on commit 04b5d65

Please sign in to comment.
Something went wrong with that request. Please try again.