Hi! Is there anyway to get notified on onClose-eve...
# ktor
g
Hi! Is there anyway to get notified on onClose-events when using websockets? I recon that you get a ClosedReceiveChannelException when you try to sendto a closed channels but I would like to get triggered as soon as a client disconnects. The Frame.Closed only seems to be sent if the user actually closes, not if they crash
c
incoming channel gets closed in any case, it is closed immediately when a disconnect is detected
g
@cy that is nice, in my case I have a set of OutgoingChannels though, so if a user get’s disconnected I want to remove them from that set, am I approaching it the wrong way?
Copy code
private val connectedPeers = mutableSetOf<SendChannel<Frame>>()
.
.
.
webSocket(prefix) {
                try {
                    peersMutext.withLock {
                        connectedPeers.add(outgoing)
                    }
....
....
}
so basically I want to know when I should/could do a connectedPeers.remove