diff --git a/relay.go b/relay.go index cfdbbf3..6f8ef6c 100644 --- a/relay.go +++ b/relay.go @@ -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) + } + } } } diff --git a/ws.go b/ws.go index 4a86177..67bb22d 100644 --- a/ws.go +++ b/ws.go @@ -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)