npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

apnsdk

v1.0.45

Published

APN Javascript SIP sofware development kit, ported from JsSIP (https://jssip.net/) javascript SIP library.

Downloads

98

Readme

Overview

  • APN --add description here
  • JsSIP as a core SIP library

Note

Getting Started

Function

apnsdk - initialize the sdk

    /**
    * @param {Object} credentials (Mandatory) 
    * credentials - {
    *   url: '<api_url>',
    *   config: {
    *       account_id: '<your-account-id>',
    *       token: '<token>',
    *       api_token: '<api_token>'
    *   },
    *   audio: { // optional
    *       ringing: '<your_custom_ringing_audio>', // mp3 or base64  
    *       ended: '<your_custom_ended_audio>',  // mp3 or base64       
    *       busy: '<your_custom_busy_audio>',  // mp3 or base64
    *   },
    *   auto_register: false, // for auto authenticate the user
    * }
    */

    apnsdk(credentials).then(/* callback function */).catch(/* callback function*/)

voiceCall - Makes an outgoing voice call.

    /**
    * https://jssip.net/documentation/api/ua/#method_call
    * @param {String} target (Mandatory) - Destination sip username or phone number.
    * @param {Object} options (Optional)
    * @param {Object} html_id (Optional) - HTML element <audio> id where the media will be attached.
    * html_id - { 'audio': '<element_id>' }
    */

    voiceCall(target, options, html_id)

videoCall - Makes an outgoing multimedia call.

    /**
    * https://jssip.net/documentation/api/ua/#method_call
    * @param {String} target (Mandatory) - Destination sip username or phone number.
    * @param {Object} options (Optional)
    * @param {Object} html_id (Optional) - HTML element <audio> and <video> id where the media will be attached.
    * html_id - { 
    *   'audio': '<element_id>',
    *   'remote_video': '<video_element_id>', 
    *   'local_video' : '<video_element_id>'
    * }
    */

    videoCall(target, options, html_id)

callAnswer - Answer the incoming call. This method is available for incoming sessions only.

    /** 
    * https://jssip.net/documentation/api/session/#method_answer
    * @param {Object} options (Optional)
    */

    callAnswer(options)

callHangup - Terminate the current session regardless its direction or state.

    /** 
    * https://jssip.net/documentation/api/session/#method_terminate
    * @param {Object} options (Optional)
    */

    callHangup(options)

refer - Transfer an ongoing call to another party.

    /** 
    * https://jssip.net/documentation/api/session/#method_refer
    * @param {String} target (Mandatory) - Destination sip username or phone number.
    * @param {Object} options (Optional)
    */

    refer(target, options)

uaUnregister - Unregister the user agent.

    /**
    * https://jssip.net/documentation/api/ua/#method_unregister
    *  @param {Object} options (Optional)
    */

    uaUnregister(options)

uaRegister - Register the user agent.

    /**
    * https://jssip.net/documentation/api/ua/#method_register
    */

    uaRegister(options)

mute - Mutes the local audio and/or video.

    /**
    * https://jssip.net/documentation/api/session/#method_mute
    * @param {Object} options (Optional)
    * options - {
    *   'audio': true,   // Local audio is muted
    *   'video': false   // Local audio is not muted   
    * }
    */

    mute(options)

unmute - Unmutes the local audio and/or video.

    /**
    * https://jssip.net/documentation/api/session/#method_unmute
    * @param {Object} options (Optional)
    * options - {
    *   'audio': true,   // Local audio is unmuted
    *   'video': false   // Local audio is muted   
    * }
    */

    unmute(options)

holdCall - Puts the call on hold.

    /**
    * https://jssip.net/documentation/api/session/#method_hold
    * @param {Object} options (Optional)
    * @param {Function} callback (Optional) - Function called once the renegotiation has succeeded.
    */
    
    holdCall(options, callback)

unHoldCall - Resumes the call from hold.

    /**
    * https://jssip.net/documentation/api/session/#method_unhold
    * @param {Object} options (Optional)
    * @param {Function} callback (Optional) - Function called once the renegotiation has succeeded.
    */

    unHoldCall(options, callback)

Usage

Using import

    import * as sdk from 'apnsdk'

    let config = {
        url: '<api url>',
        config: {
            token: '<your-account-token>',          
            account_id: '<your-account-id>',               
        },
        auto_register: false, 
    }

    sdk.apnsdk(config)
    .then(/*callback function*/)
    .catch(/*error handler function*/)
    
    // OR

    import {apnsdk, voiceCall} from 'apnsdk'

    let config = {
        url: '<api url>',
        config: {
            token: '<your-account-token>',          
            account_id: '<your-account-id>',               
        },
        auto_register: false, 
    }

    apnsdk(config)
    .then(/*callback function*/)
    .catch(/*error handler function*/)

Bundled minified

    <script src="<your-path>/apnsdk.min.js"></script>
    
    <script type="text/javascript">
        apnsdk({
            url: '<api url>',
            config: {
                token: '<your-account-token>',          
                account_id: '<your-account-id>',               
            },
            auto_register: false, 
        })
        .then(/*callback function*/)
        .catch(/*error handler function*/)
    </script>

Sample

    // Initialize the sdk
    apnsdk({
        url: 'https://test.com',
        config: {
            account_id: '80668D7D-8965-4BFD-BF1D-EDCA66FC2024',
            token: '9e9a4dd202fe02455ec08e5037719506f78fee5e8704089718835df9d5f3ec24'
        },
        auto_register: false,
    }).then((ua) => {
        /**
        * Update UI here
        */

        // (https://jssip.net/documentation/api/ua/)
        this.ua = ua.user_agent

        // (https://jssip.net/documentation/api/ua/#section_events)
        this.ua.on('connected', (e) => {
            // console.log('User connected.')
        })

        this.ua.on('disconnected', (e) => {
            // console.log('User disconnected.');
        });

        this.ua.on('registered', (e) => {
            // console.log('User registered.');
        });

        this.ua.on('unregistered', (e) => {
            // console.log('User unregistered.')
        });

        this.ua.on('registrationFailed', (e) => {
            // causes - https://jssip.net/documentation/api/causes/
            // console.log('Registration failed, ' + e.cause)
        })

        // (https://jssip.net/documentation/api/session/)
        this.ua.on('newRTCSession', (e) => {
            let session = e.session;

            let completeSession = () => {
                session = null;
                // console.log('Session ended.')
            };

            if(session.direction === 'incoming'){
                // event for inbound call
            }
            
            // (https://jssip.net/documentation/api/session/#section_events)
            session.on('ended', (e) => {
                // https://jssip.net/documentation/api/causes/
                // console.log('Ended: ', e.cause)
                completeSession()
            });

            session.on('failed', (e) => {
                // https://jssip.net/documentation/api/causes/
                console.log('Failed: ', e.cause)
                completeSession()
            });

            session.on('accepted', (e) => {
                // when outbound call is answered
            });
        })
    }).catch((error) => {
        // TODO: Update UI here etc.
    })