- Notifications
You must be signed in to change notification settings - Fork714
A simple, intuitive, and powerful JavaScript signaling library
License
NotificationsYou must be signed in to change notification settings
onsip/SIP.js
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
- Create real-time peer-to-peer audio and video sessions viaWebRTC
- Utilize SIP in your web application viaSIP over WebSocket
- Send instant messages and view presence
- Support early media, hold and transfers
- Send DTMF RFC 2833 or SIP INFO
- Share your screen or desktop
- Written in TypeScript
- Runs in all major web browsers
- Compatible with standards compliant servers includingAsterisk andFreeSWITCH
Want see it in action? The project website,sipjs.com, has alive demo.
Looking for code to get started with? This repository includesdemonstrations which run in a web browser.
To place a SIP call, either utilize theSimpleUser
class...
import{Web}from"sip.js";// Helper function to get an HTML audio elementfunctiongetAudioElement(id:string):HTMLAudioElement{constel=document.getElementById(id);if(!(elinstanceofHTMLAudioElement)){thrownewError(`Element "${id}" not found or not an audio element.`);}returnel;}// Options for SimpleUserconstoptions:Web.SimpleUserOptions={aor:"sip:alice@example.com",// callermedia:{constraints:{audio:true,video:false},// audio only callremote:{audio:getAudioElement("remoteAudio")}// play remote audio}};// WebSocket server to connect withconstserver="wss://sip.example.com";// Construct a SimpleUser instanceconstsimpleUser=newWeb.SimpleUser(server,options);// Connect to server and place callsimpleUser.connect().then(()=>simpleUser.call("sip:bob@example.com")).catch((error:Error)=>{// Call failed});
Or, alternatively, use the fullAPI framework...
import{Inviter,SessionState,UserAgent}from"sip.js";// Create user agent instance (caller)constuserAgent=newUserAgent({uri:UserAgent.makeURI("sip:alice@example.com"),transportOptions:{server:"wss://sip.example.com"},});// Connect the user agentuserAgent.start().then(()=>{// Set target destination (callee)consttarget=UserAgent.makeURI("sip:bob@example.com");if(!target){thrownewError("Failed to create target URI.");}// Create a user agent client to establish a sessionconstinviter=newInviter(userAgent,target,{sessionDescriptionHandlerOptions:{constraints:{audio:true,video:false}}});// Handle outgoing session state changesinviter.stateChange.addListener((newState)=>{switch(newState){caseSessionState.Establishing:// Session is establishingbreak;caseSessionState.Established:// Session has been establishedbreak;caseSessionState.Terminated:// Session has terminatedbreak;default:break;}});// Send initial INVITE requestinviter.invite().then(()=>{// INVITE sent}).catch((error:Error)=>{// INVITE did not send});});
Node module
npm install sip.js
UMD bundle
- Downloadsipjs.com/download
- CDNjsDelivr.com
Clone this repository, then...
npm installnpm run build-and-test
For more info please see theDocumentation.
- For migration guides and API reference please see theDocumentation.
- For bug reports and feature requests please open aGitHub Issue.
- For questions or usage problems please use theGoogle Group.
- For more information see the project website atSIPjs.com.
About
A simple, intuitive, and powerful JavaScript signaling library
Topics
Resources
License
Security policy
Stars
Watchers
Forks
Packages0
No packages published