To get the full experience, download the latest version of Chrome or Firefox
The code displayed on the right is what powers the selected demo from Alice’s end, although Bob’s code would be very similar. SIP.js allows you to utilize WebRTC’s APIs using just JavaScript. To check out the full code for all three demos, click the button below.
SIP.js makes it easy to utilize WebRTC's APIs and set up SIP communication sessions. In no time at all, you can have two separate users talking to one another. To learn more about the SIP.js API, click the button below.
const domain = 'sipjs.onsip.com';
const aliceURI = 'alice.' + window.token + '@' + domain;
const aliceName = 'Alice';
const bobURI = 'bob.' + window.token + '@' + domain;
const bobName = 'Bob';
const remoteVideoElement = document.getElementById(remoteVideo);
const button = document.getElementById(buttonId);
let onCall = false;
const configuration = {
aor: aliceURI,
delegate: {
onCallCreated: () => {
onCall = true;
},
onCallAnswered: () => {
onCall = true;
},
onCallHangup: () => {
onCall = false;
}
}
media: {
remote: {
video: remoteVideoElement,
// Need audio to be not null to do audio & video instead of just video
audio: remoteVideoElement
}
},
userAgentOptions: {
displayName
},
};
const simpleUser = new SimpleUser('wss://edge.sip.onsip.com', configuration);
simpleUser.connect();
button.addEventListener('click', function() {
// No current call up
if (!onCall) {
simpleUser.call(bobURI);
} else {
simple.hangup();
}
});
const domain = 'sipjs.onsip.com';
const aliceURI = 'alice' + '@' + domain;
const aliceName = 'Alice';
const bobURI = 'bob' + '@' + domain;
const bobName = 'Bob';
const configuration = {
aor: aliceURI,
delegate: {
onMessage: (msg) => {
alert(msg.body);
}
}
};
const aliceSimple = new SimpleUser('wss://edge.sip.onsip.com', configuration);
aliceSimple.message(bobURI, 'Check out this palindrome: "Now sir, a war is never even. Sir, a war is won."');
If you’d like to identify and locate your user addresses on the Internet so they can participate in RTC sessions, you’ll need SIP servers. You can build your own using open source FreeSWITCH or Asterisk, or you can try out OnSIP - no system setup, modifications, maintenance, or upfront capital required. Sign up for an OnSIP free trial ⟩
Sign up for an OnSIP free trial ⟩New to SIP.js? Our guides and docs will have you up and running in a snap.
Get answers, stay up to date, and become part of the SIP.js community.