Commit 3ea63c39 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Implement abort message in the downstream direction.

This is not quite correct, we're sending a spurious close.
parent 8bfdc2b0
...@@ -761,7 +761,11 @@ func handleClientMessage(c *client, m clientMessage) error { ...@@ -761,7 +761,11 @@ func handleClientMessage(c *client, m clientMessage) error {
switch m.Type { switch m.Type {
case "offer": case "offer":
if !c.permissions.Present { if !c.permissions.Present {
return userError("not authorised") c.write(clientMessage{
Type: "abort",
Id: m.Id,
})
return c.error(userError("not authorised"))
} }
if m.Offer == nil { if m.Offer == nil {
return protocolError("null offer") return protocolError("null offer")
......
...@@ -316,6 +316,9 @@ function serverConnect() { ...@@ -316,6 +316,9 @@ function serverConnect() {
case 'close': case 'close':
gotClose(m.id); gotClose(m.id);
break; break;
case 'abort':
gotAbort(m.id);
break;
case 'ice': case 'ice':
gotICE(m.id, m.candidate); gotICE(m.id, m.candidate);
break; break;
...@@ -408,6 +411,24 @@ function gotClose(id) { ...@@ -408,6 +411,24 @@ function gotClose(id) {
delMedia(id); delMedia(id);
} }
function gotAbort(id) {
let c = up[id];
if(!c)
throw new Error('unknown up stream in abort');
if(id === localMediaId) {
document.getElementById('presenterbox').checked = false;
setLocalMedia();
} else if(id === shareMediaId) {
document.getElementById('sharebox').checked = false;
setShareMedia();
} else {
console.error('Strange stream in abort');
delMedia(id);
c.pc.close();
delete(up[id]);
}
}
async function gotICE(id, candidate) { async function gotICE(id, candidate) {
let conn = up[id]; let conn = up[id];
if(!conn) if(!conn)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment