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

react-native-webrtc-simple

v1.4.2

Published

A simple and easy to use module that help in making video call for React Native.

Downloads

56

Readme

react-native-webrtc-simple

A simple and easy to use module that help in making video call for React Native. Implemented using react-native-webrtc.

Getting started

npm install react-native-webrtc-simple --save

or

yarn add react-native-webrtc-simple

Now we need to install react-native-webrtc

Document

WebrtcSimple

| Method | Description | | ---------------------------- | ----------------------------- | | start | Create connections | | stop | Stop connections | | getSessionId | Get your session id | | getLocalStream | Get your video stream | | getRemoteStream | Get remote video stream | | listenings | Listenings call events | | events | Method call events |

WebrtcSimple.start

| Value | Type | Description | | -------- | -------------- | ----------------------------------------------------------------------- | | optional | Object or null | Option peer configuration (https://peerjs.com/) | | key | String | Your session id |

Peer-to-Peer

WebrtcSimple.listenings.callEvents

| Value | Type | Description | | ---------------- | ------- | ----------------------------------------------------------------------- | | START_CALL | String | Your start call status | | RECEIVED_CALL | String | Call received status | | ACCEPT_CALL | String | Call aceept status | | END_CALL | String | Call end status | | MESSAGE | String | Listenings a message |

WebrtcSimple.events

| Method | Params | Description | | --------------| ------------------------------ | ----------------------------------------------------------------------- | | call | sessionId:String, data:any | Initiate a call | | acceptCall | No | Accept a call | | endCall | No | Reject a call | | switchCamera | No | Switch camera | | videoEnable | No | On/Off video | | audioEnable | No | On/Off audio | | message | data:any | Events send message |

Multiple Peer

WebrtcSimple.listenings.callEvents

| Value | Type | Description | | -------------------- | ------- | ----------------------------------------------------------------------- | | START_GROUP_CALL | String | Your start call status | | RECEIVED_GROUP_CALL | String | Call received status | | JOIN_GROUP_CALL | String | Call received status | | LEAVE_GROUP_CALL | String | Call reject status |

WebrtcSimple.events

| Method | Params | Description | | --------------| ----------------------------------------------- | ----------------------------------------------------------------------- | | groupCall | groupSessionId: string[], userData: object = {} | Start group call | | joinGroup | arrSessionId: string[] | Join group call | | leaveGroup | No | Leave group call | | addStream | sessionId: string | Create a stream | | switchCamera | No | Switch camera | | videoEnable | No | On/Off video | | audioEnable | No | On/Off audio | | message | data:any | Events send message |

Usage

import WebrtcSimple from 'react-native-webrtc-simple';

useEffect(() => {
    const configuration = {
      optional: null,
      key: Math.random().toString(36).substr(2, 4), //optional
    };

    WebrtcSimple.start(configuration)
        .then((status) => {
        if (status) {
            const stream = WebrtcSimple.getLocalStream();
            console.log('My stream: ', stream);

            WebrtcSimple.getSessionId((id: string) => {
                console.log('UserId: ', id);
            });
        }
        })
        .catch();

    WebrtcSimple.listenings.callEvents((type, userData) => {
      console.log('Type: ', type);
      // START_CALL
      // RECEIVED_CALL
      // ACCEPT_CALL
      // END_CALL
      // MESSAGE
      // START_GROUP_CALL
      // RECEIVED_GROUP_CALL
      // JOIN_GROUP_CALL
      // LEAVE_GROUP_CALL
    });

    WebrtcSimple.listenings.getRemoteStream((remoteStream) => {
      console.log('Remote stream', remoteStream);
    });

}, []);

const callToUser = (userId) => {
  const data = {};
  WebrtcSimple.events.call(userId, data);
};

const acceptCall = () => {
  WebrtcSimple.events.acceptCall();
};

const endCall = () => {
  WebrtcSimple.events.endCall();
};

const switchCamera = () => {
  WebrtcSimple.events.switchCamera();
};

const video = (enable: boolean) => {
  WebrtcSimple.events.videoEnable(enable);
};

const audio = (enable: boolean) => {
  WebrtcSimple.events.audioEnable(enable);
};

const sendMessage = (message: any) => {
    WebrtcSimple.events.message(message);
};

const groupCall = (sessionId: string[]) => {
    const data = {};
    WebrtcSimple.events.groupCall(sessionId, data);
};

const joinGroup = (groupSessionId: string[]) => {
  WebrtcSimple.events.joinGroup(groupSessionId);
};

const leaveGroup = () => {
  WebrtcSimple.events.leaveGroup();
};