Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A simple, intuitive, and powerful JavaScript signaling library

License

NotificationsYou must be signed in to change notification settings

onsip/SIP.js

Repository files navigation

SIP.js Logo

Build Statusnpm version

SIP Library for JavaScript

  • 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

Demo

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.

Usage

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});});

Installation

Node module

npm install sip.js

UMD bundle

Building, Development and Testing

Clone this repository, then...

npm installnpm run build-and-test

For more info please see theDocumentation.

Support

  • 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.

[8]ページ先頭

©2009-2025 Movatter.jp