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 🙏

© 2025 – Pkg Stats / Ryan Hefner

videocall-client-socket

v0.1.7

Published

WebRTC client for peer-to-peer video calls using socket.io and simple-peer.

Readme

📞 videocall-socket-client

A simple WebRTC client library for peer-to-peer video calls using simple-peer and socket.io-client.

✅ Designed to work with videocall-server


📦 Installation

npm install videocall-client-socket

⚠️IMPORTANT!!!⚠️ This package expects simple-peer to be loaded via CDN in your HTML. ✅ Add this in your head:

<script src="https://cdn.jsdelivr.net/npm/simple-peer/simplepeer.min.js"></script>

This makes SimplePeer available globally in the browser.


🚀 Quick Start

import * as VideoClient from "videocall-client-socket";
import { v4 as uuidv4 } from "uuid";

const userId = uuidv4();
const channelName = "roomABC";

// Step 1: Subscribe to events before anything else
VideoClient.on("user-published", (data) => {
  const { user, mediaType } = data;
  const video = document.createElement("video");
  video.srcObject = user.videotrack;
  video.autoplay = true;
  video.id = user.uuid;
  document.body.appendChild(video);
});
VideoClient.on("user-unpublished", (data) => {
  const { user, mediaType } = data;
  if (mediaType === "video") {
    const video = document.getElementById(`${user.uuid}`);
    if (video) {
      video.remove();
    }
  }
});
VideoClient.on("user-media-toggled", (data) => {
  console.log(data.user.uuid, data.type, data.enabled);
});

// Step 2: Create media stream
SocketClient.createMediaStream()
  .then(() => {
    // Step 3: Play local stream in <video> tag
    VideoClient.playVideoTrack("localVideo");
    SocketClient.joinChannel(userId, channelName);

    // Step 4: Join the signaling channel
    //IMPORTANT: The service repository is located at the bottom.
    VideoClient.setServerURL("http://localhost:3000");
    VideoClient.joinChannel(userId, channelName);
  })
  .catch((err) => {
    console.error(err);
  });

📋 Execution Order

To use this library correctly, follow this sequence of steps:

| Step | Function | Why? | | ---- | -------------------------------- | -------------------------------------------------------------- | | 1️⃣ | on(...) | You must subscribe to events before joining the channel. | | 2️⃣ | createMediaStream() | This requests access to camera and microphone. | | 3️⃣ | playVideoTrack(videoElementId) | This shows your local stream in a <video> tag. | | 4️⃣ | joinChannel(userId, room) | Finally, join the signaling server and start peer connections. |

🧠 Skipping or reordering these steps may cause video/audio to not work properly or event listeners to be missed.


📘 API Reference

🔌 Connection

  • setServerURL(url: string): void
  • joinChannel(userId: string, room: string): void
  • leaveChannel(): void

🎥 Media Controls

  • createMediaStream(): Promise<MediaStream>
  • playVideoTrack(localVideoId: string): void
  • toggleCamera(on: boolean): void
  • isCameraOn(): boolean
  • toggleAudio(on: boolean): void
  • isAudioOn(): boolean

📡 Events System

Use on(event, callback) and off(event, callback).

  • user-published: { user: { uuid, videotrack }, mediaType }
  • user-unpublished: { user: { uuid }, mediaType }
  • user-media-toggled: { user: { uuid }, type, enabled }

Example:

VideoClient.on("user-published", ({ user }) => {
  const video = document.createElement("video");
  video.srcObject = user.videotrack;
  video.autoplay = true;
  video.id = user.uuid;
  document.body.appendChild(video);
});

🧩 Backend Integration

This library is designed to work with the following signaling server:

🔗 videocall-server

git clone https://github.com/EmersonJaraG28/videocall-server.git
cd videocall-server
npm install
npm run dev

📚 Related Libraries


🧾 License

ISC © Jara