Skip to content

Instantly share code, notes, and snippets.

@rsatrio
Created June 13, 2022 03:21
Show Gist options
  • Save rsatrio/ed9faab106285394d27d7e0f58668702 to your computer and use it in GitHub Desktop.
Save rsatrio/ed9faab106285394d27d7e0f58668702 to your computer and use it in GitHub Desktop.
rtcPeer.onicecandidate = event => {
console.log('Got ice candidate');
if (event.candidate) {
console.log('ice candidate:' + JSON.stringify(event.candidate));
signal1.userId = userId2;
signal1.type = 'Ice';
signal1.data = JSON.stringify(event.candidate);
signal1.toUid = data1.userId;
}
console.log('ice candidate2:' + JSON.stringify(event));
if (event.candidate) {
if (Object.keys(event.candidate.candidate).length > 1) {
console.log("Sending candidate to server");
ws1.send(JSON.stringify(signal1));
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment