mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 05:49:22 +00:00
Handles remote signals
This commit is contained in:
parent
f3ae21c5c1
commit
dea30cb0ce
@ -229,6 +229,10 @@ class UserWebSocket {
|
|||||||
SendEvent("userLeftCall", msg.data);
|
SendEvent("userLeftCall", msg.data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "new_call_signal":
|
||||||
|
SendEvent("newCallSignal", msg.data);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
console.error("WS Unspported kind of message!", msg);
|
console.error("WS Unspported kind of message!", msg);
|
||||||
break;
|
break;
|
||||||
|
@ -90,6 +90,13 @@ document.addEventListener("userLeftCall", (e) => {
|
|||||||
OpenConversations.get(detail.callID).RemoveMember(detail.userID)
|
OpenConversations.get(detail.callID).RemoveMember(detail.userID)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
document.addEventListener("newCallSignal", (e) => {
|
||||||
|
const detail = e.detail
|
||||||
|
|
||||||
|
if(OpenConversations.has(detail.callID))
|
||||||
|
OpenConversations.get(detail.callID).NewSignal(detail.peerID, detail.data)
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener("wsClosed", () => {
|
document.addEventListener("wsClosed", () => {
|
||||||
// Close all the current conversations
|
// Close all the current conversations
|
||||||
|
@ -271,5 +271,32 @@ class CallWindow extends CustomEvents {
|
|||||||
console.error("Peer error!", err);
|
console.error("Peer error!", err);
|
||||||
notify("An error occured while trying to connect!", "danger", 5)
|
notify("An error occured while trying to connect!", "danger", 5)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.mainPeer.on("connect", () => console.info("Connected to remote peer!"))
|
||||||
|
|
||||||
|
this.mainPeer.on("message", message => {
|
||||||
|
console.log("Message from remote peer: " + message);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.mainPeer.on("stream", stream => {
|
||||||
|
console.log("mainPeer stream", stream)
|
||||||
|
alert("Stream on main peer!!!")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles new signals
|
||||||
|
*
|
||||||
|
* @param {Number} peerID Target peer ID
|
||||||
|
* @param {any} data Signal data
|
||||||
|
*/
|
||||||
|
NewSignal(peerID, data) {
|
||||||
|
|
||||||
|
if(peerID == userID())
|
||||||
|
this.mainPeer.signal(data)
|
||||||
|
|
||||||
|
else
|
||||||
|
console.error("Unsupported type of signal!")
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user