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

stringee

v2.9.3

Published

The Stringee communication platform makes it easy to embed high-quality interactive video, voice, SMS into webs and mobile apps.

Downloads

229

Readme

A library to build high-quality voice, video applications in the Cloud. With this library, you can:

  • you can make voice calls or video calls
  • proactive call control
  • View Sample

Table of Contents

Install SDK from NPM Create StringeeClient
Setup voice call
Set up video call

Install SDK from NPM

npm install stringee

Create StringeeClient

import { StringeeUtil, StringeeClient, StringeeCall, StringeeCall2 } from "stringee";

const client = new StringeeClient();

client.on("connect", () => {
    // connected to StringeeServer
});

client.on("authen", (response) => {
    // on authen user, response object
    // {
    //     r               : 0
    //     requestId       : 1
    //     clients         : [{…}]
    //     connectionId    : 123456789
    //     ping_after_ms   : 45000
    //     projectId       : 1234
    //     userId          : "abc"
    //     ice_servers     : [{…}, {…}, {…}, {…}]
    //     message         : "SUCCESS"
    // }
    // response success: r = 0
    // response error: r != 0 and message : "Error message"
});

client.on("disconnect", () => {
    //disconnected
});

client.on("incomingcall", (incomingcall) => {
    // Setup voice call
});


client.on("incomingcall2", (call2) => {
    // Setup video call
});

client.on("requestnewtoken", () => {
    // request new token;
    // please get new access_token from YourServer
    // and call client.connect(new_access_token)
});

client.on("otherdeviceauthen", (data) => {
    console.log("otherdeviceauthen: ", data);
});


stringeeClient.connect(accessToken);

Setup voice call

<!-- Create video tag -->
<video id="remoteVideo" playsinline autoplay style="width: 350px"></video>

Make the voice call

var call = new StringeeCall(stringeeClient, from, to);

// SETTING CALL EVENTS
    call.on("error", (info) => {
        // on error
    });
    call.on("addlocalstream", (stream) => {
        // on add local stream
    });
    call.on("addremotestream", (stream) => {
        // on add remote stream
    });
    call.on("signalingstate", (state) => {
        // signalingstate

        if (state.code == 6) {// call ended
            incomingCallDiv.style.display = "none";
            callStopped();
        }

        if (state.code == 5) {// busy here
            callStopped();
        }

        const reason = state.reason;
        callStatus.innerHTML = reason;
    });
    call.on("mediastate", (state) => {
        // mediastate 
    });
    call.on("info", (info) => {
        // on info
    });
    call.on("otherdevice", (data) => {
        // "on otherdevice
    });

// MAKE CALL
    call.makeCall((response) => {
        // response json data success
        // {
        //     r                        : 0,
        //     callId                   : "call-vn-1-D2BIJCH2U9-1686467352064",
        //     fromNumber               : "FROM_NUMBER",
        //     customDataFromYourServer : "",
        //     toType                   : "internal",
        //     requestId                : 9,
        //     video                    : false,
        //     message                  : "SUCCESS",
        //     toNumber                 : "TO_NUMBER",
        //     peerToPeerCall           : true
        // }
        
    });

// AFTER THEN 
call.hangup((res) => {
    // hangup res
    // and remove source remote video
    remoteVideo.srcObject = null;
});

Receiving the voice call

client.on("incomingcall", (incomingcall) => {
    // Object incomingcall is StringeeCall    
    // reassign incomingcall to call
    call = incomingcall;

    // you can call SETTING CALL EVENTS
});

// Answare the call
call.answer((res) => {
    // answer res
});
// OR Reject the call
call.reject((response) => {
    // reject res
});

Set up video call

Make the video call

var call = new StringeeCall2(stringeeClient, FROM_NUMBER, TO_NUMBER, true);

// SETTING CALL EVENT
    call.on("addlocaltrack", (localtrack) => {
        // add local track
    });
    call.on("addremotetrack", (track) => {
        // add remote track
    });
    call.on("removeremotetrack", (track) => {
        // remove remote track
        track.detachAndRemove();
    });
    call.on("removelocaltrack", (track) => {
        track.detachAndRemove();
    });
    call.on("signalingstate", (state) => {
        // signalingstate object
        // {
        //     code      : 6
        //     reason    : "Ended"
        //     sipCode   : SIP_CODE
        //     sipReason : SIP_REASON
        // }
    });
    call.on("mediastate", (state) => {
        // mediastate
    });
    call.on("otherdevice", (msg) => {
        // otherdevice
    });
    call.on("info", (info) => {
        // receiving info
    });

// MAKE CALL
call.makeCall((response) => {
    // response object
    // {
    //     r         : 0
    //     requestId : 2
    //     callId    : "call-vn-1-D2BIJCH2U9-1686467455592"
    //     message   : "SUCCESS"
    // }
});

// HANGUP
    call.hangup((res) => {});
    // at the same time we remove all video tracks
    call.subscribedTracks.forEach((track) => {
        track.detachAndRemove();
    });

// MUTE
    call.mute(true);

// SEND INFO
    call.sendInfo({ a: "hello", b: 1 }, (res) => {});

// ENABLE/DISABLE VIDEO
    // disable Local Video
    call.enableLocalVideo(false);
    // enable Local Video
    call.enableLocalVideo(true);

// SWITCH CAMERA (mobile only)
    call.switchCamera();

// Transfer
    // TYPE is string and value in list ['agent', 'queue']
    // TYPE_VALUE is string and value in list ['blind', 'attended', 'conference', 'coach']
    call.transferCall(to, TYPE, TYPE_VALUE, console.log);

// HOLD VIDEO CALL
    call.sendHold(null, (h) => {});
    call.sendUnHold((h) => {});

// LEAVE ROOM
    call.leaveRoom();

Receiving the video call

client.on("incomingcall2", (call2) => {
    // Object incomingcall is StringeeCall2    
    // reassign call2 to call
    call = call2;

    // then you should call SETTING CALL EVENTS
});