Skip to content

Instantly share code, notes, and snippets.

@SumindaD
Created October 10, 2019 06:51
Show Gist options
  • Save SumindaD/9f6c5678c44d81082c7bf38b9d663927 to your computer and use it in GitHub Desktop.
Save SumindaD/9f6c5678c44d81082c7bf38b9d663927 to your computer and use it in GitHub Desktop.
function createAndSendAnswer(){
// Create Answer
connection.createAnswer().then(
answer => {
log('Sent The Answer.');
// Set Answer for negotiation
connection.setLocalDescription(answer);
// Send Answer to other peer
socket.send(JSON.stringify(
{
action: 'onMessage',
type: 'answer',
data: answer,
id: clientId
}
));
},
error => {
log('Error when creating an answer.');
console.error(error);
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment