3 Commits

Author SHA1 Message Date
spynup
ecd836af75 Listen to CloseNotifier in stream handler.
Problem:

context.Stream() already listens to the closeNotifier, which gives the impression that context.Stream() will return as soon as a client disconnects.  Unfortunately, it doesn't!

This example code furthers the impression with the defer closeListener(roomid, listener) which one would expect to be called when a client navigates away, which is not the case.  In fact, it's only called on the next message that's sent to the room after said client exits. 

This is because c.SSEvent("message", <-listener) blocks indefinitely until a message comes in, so will not return and yield to c.Stream()'s select that catches the closeNotify.  This means that if a client navigates away, the server never notices and cleans up.

Fix: Also listen to CloseNotifier inside stream handler.  This causes the step() function to return immediately when the client goes away and allows the cleanup to run.  Updating this example should make it more clear, I think!
2015-07-22 12:20:47 -07:00
Manu Mtz-Almeida
4797530476 Fixes example code 2015-05-26 12:15:43 +02:00
Manu Mtz-Almeida
15b0c49da5 Adds realtime-chat example code 2015-05-12 19:23:54 +02:00