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 {