Can request to close a connection

This commit is contained in:
Pierre HUBERT 2020-04-11 18:02:50 +02:00
parent d1a79f49ac
commit d2d2dedf92
2 changed files with 17 additions and 0 deletions

View File

@ -411,6 +411,18 @@ func newCall(mainOffer receivedSignal, r activeRelay) {
log.Printf("Err tried to add ICE Candidate for non ready peer connection!")
}
} else if newMessage.sigType == CloseConnection {
// Check if we have to close the whole connection or just a client
if newMessage.peerID == "0" {
askForClose(r)
return
} else if val, ok := clients[newMessage.peerID]; ok {
// Close a single client
val.Close()
delete(clients, newMessage.peerID)
}
}
}
}

5
ws.go
View File

@ -82,6 +82,11 @@ func openWs(conf *Config) {
onSignal(msg.CallHash, msg.PeerID, msg.Data.(map[string]interface{}))
break
// Close a connection
case "close_conn":
onCloseConnection(msg.CallHash, msg.PeerID)
break
default:
println("Received unkown message type!")
log.Printf("recv: %s", message)