From 1e29c62378c9592653100bc39c244594f959c622 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Mon, 13 Apr 2020 08:05:52 +0200 Subject: [PATCH] Ensure all clients connection automatically close --- relay.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/relay.go b/relay.go index f8ec67b..693f902 100644 --- a/relay.go +++ b/relay.go @@ -157,7 +157,6 @@ func onCloseConnection(callHash, peerID string) { /// Close a connection func closeConnection(r *activeRelay) { - log.Printf("Closing call %s / id: %d", r.callHash, r.id) // Close the channel if !r.closed { @@ -169,6 +168,8 @@ func closeConnection(r *activeRelay) { if val, ok := connections[r.callHash]; ok && val.id == r.id { delete(connections, r.callHash) } + + log.Printf("Closing call %s / id: %d (%d remaining open calls)", r.callHash, r.id, len(connections)) } // Ask for a channel to be closed @@ -438,6 +439,8 @@ func newCall(mainOffer receivedSignal, r *activeRelay) { } clients[newMessage.peerID] = newPeerConnection + defer newPeerConnection.Close() + // Send ice candidates newPeerConnection.OnICECandidate(func(c *webrtc.ICECandidate) { if c == nil || r.closed {