Prefer `.addEventListener()`.
parent
2839c87aed
commit
d0bd78850e
|
|
@ -25,7 +25,7 @@ function pageReady() {
|
||||||
remoteVideo = document.getElementById('remoteVideo');
|
remoteVideo = document.getElementById('remoteVideo');
|
||||||
|
|
||||||
serverConnection = new WebSocket('wss://' + window.location.hostname + ':8443');
|
serverConnection = new WebSocket('wss://' + window.location.hostname + ':8443');
|
||||||
serverConnection.onmessage = gotMessageFromServer;
|
serverConnection.addEventListener('message', gotMessageFromServer);
|
||||||
|
|
||||||
var constraints = {
|
var constraints = {
|
||||||
video: true,
|
video: true,
|
||||||
|
|
@ -47,30 +47,30 @@ function getUserMediaSuccess(stream) {
|
||||||
function start(isCaller) {
|
function start(isCaller) {
|
||||||
peerConnection = new RTCPeerConnection(peerConnectionConfig);
|
peerConnection = new RTCPeerConnection(peerConnectionConfig);
|
||||||
|
|
||||||
peerConnection.onicecandidate = gotIceCandidate;
|
peerConnection.addEventListener('icecandidate', gotIceCandidate);
|
||||||
peerConnection.onaddstream = gotRemoteStream;
|
peerConnection.addEventListener('addstream', gotRemoteStream);
|
||||||
peerConnection.addStream(localStream);
|
peerConnection.addStream(localStream);
|
||||||
|
|
||||||
peerConnection.ondatachannel = function(dataChannel) {
|
peerConnection.addEventListener('datachannel', function(dataChannel) {
|
||||||
dataChannel.channel.send('Hello there, I got your signal');
|
dataChannel.channel.send('Hello there, I got your signal');
|
||||||
}
|
});
|
||||||
|
|
||||||
dataChannel = peerConnection.createDataChannel("myLabel", dataChannelOptions);
|
dataChannel = peerConnection.createDataChannel("myLabel", dataChannelOptions);
|
||||||
dataChannel.onerror = function (error) {
|
dataChannel.addEventListener('error', function (error) {
|
||||||
console.log("Data Channel Error:", error);
|
console.log("Data Channel Error:", error);
|
||||||
};
|
});
|
||||||
|
|
||||||
dataChannel.onmessage = function (event) {
|
dataChannel.addEventListener('message', function (event) {
|
||||||
console.log("Got Data Channel Message:", event.data);
|
console.log("Got Data Channel Message:", event.data);
|
||||||
};
|
});
|
||||||
|
|
||||||
dataChannel.onopen = function (event) {
|
dataChannel.addEventListener('open', function (event) {
|
||||||
console.log("Datachannel open", event);
|
console.log("Datachannel open", event);
|
||||||
};
|
});
|
||||||
|
|
||||||
dataChannel.onclose = function () {
|
dataChannel.addEventListener('close', function () {
|
||||||
console.log("The Data Channel is Closed");
|
console.log("The Data Channel is Closed");
|
||||||
};
|
});
|
||||||
|
|
||||||
if(isCaller) {
|
if(isCaller) {
|
||||||
peerConnection.createOffer().then(createdDescription).catch(errorHandler);
|
peerConnection.createOffer().then(createdDescription).catch(errorHandler);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue