jarohen / chord

A library designed to bridge the gap between the triad of CLJ/CLJS, web-sockets and core.async.
439 stars 40 forks source link

How do I clean up after a client disconnects? #34

Closed magnars closed 9 years ago

magnars commented 9 years ago

Thanks for making chord - websockets and core.async is a great match. :-)

One issue: Are there any notifications or callbacks for when a client disconnects? In particular for this websocket endpoint that only sends data, and doesn't receive any. Or do I have to create some manual ACK from the client along with timeouts?

magnars commented 9 years ago

@james-henderson A quick question, hope you have time to look at it. :) Thanks!

jarohen commented 9 years ago

Hi Magnars - sorry for not getting back to you sooner. Yes - when a client disconnects, Chord closes the core.async channel - so when you pull a message off the channel, if you find that it's nil, the channel's been closed, and you should do any necessary cleanup.

Have gone into more detail in #31, if that helps!

Cheers,

James

magnars commented 9 years ago

Aha, so I don't need any ACKs, I can just read off the channel (even if no-one is sending anything to it), and when it closes it will return with nil. That makes perfect sense. Thank you!