diff --git a/rtpconn/webclient.go b/rtpconn/webclient.go index 263e378..53bde11 100644 --- a/rtpconn/webclient.go +++ b/rtpconn/webclient.go @@ -1144,6 +1144,15 @@ func handleClientMessage(c *webClient, m clientMessage) error { if !found { log.Printf("Deleting unknown up connection %v", m.Id) } + case "abort": + found := delDownConn(c, m.Id) + if !found { + log.Printf("Attempted to abort unknown connection") + } + c.write(clientMessage{ + Type: "close", + Id: m.Id, + }); case "ice": if m.Candidate == nil { return group.ProtocolError("null candidate") diff --git a/static/protocol.js b/static/protocol.js index b93667e..2f89f15 100644 --- a/static/protocol.js +++ b/static/protocol.js @@ -911,6 +911,10 @@ function Stream(sc, id, pc, up) { /** * close closes a stream. + * + * For streams in the up direction, this may be called at any time. For + * streams in the down direction, this will be called automatically when + * the server signals that it is closing a stream. */ Stream.prototype.close = function() { let c = this; @@ -941,6 +945,19 @@ Stream.prototype.close = function() { c.sc = null; }; +/** + * abort requests that the server close a down stream. + */ +Stream.prototype.abort = function() { + let c = this; + if(c.up) + throw new Error("Abort called on an up stream"); + c.sc.send({ + type: 'abort', + id: c.id, + }); +} + /** * Called when we get a local ICE candidate. Don't call this. *