Ensure all clients connection automatically close

This commit is contained in:
Pierre HUBERT 2020-04-13 08:05:52 +02:00
parent b117cd31d0
commit 1e29c62378

View File

@ -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 {