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

@tlaukkan/webrtc-signaling

v0.0.22

Published

WebRTC Signaling with Node.js WebSocket server.

Downloads

14

Readme

WebRTC Signaling with Node.js WebSocket

This library implements signaling client and server for WebRTC utilising Node.js WebSocket server.

Usage

Your ID in the signaling server is created by taking SHA256 hash from email + secret token you pass in the client constructor.

Example


const SignalingChannel = require('../../src/signaling-channel').SignalingChannel;

const configuration = { iceServers: [{urls: 'stun:stun1.l.google.com:19302'}] };
const signalingServerUrl = 'wss://tlaukkan-webrtc-signaling.herokuapp.com/'

const signalingChannelOne = new SignalingChannel(WebSocket)
signalingChannelOne.autoReconnect = false
signalingChannelOne.addServer(signalingServerUrl, '[email protected]', uuidv4())

const signalingChannelTwo = new SignalingChannel(WebSocket)
signalingChannelTwo.autoReconnect = false
signalingChannelTwo.addServer(signalingServerUrl, '[email protected]', uuidv4(), async (receivedSignalingServerUrl, selfPeerId) => {
    // Offer data channel with signaling channel one.
    const connection = new RTCPeerConnection(configuration)
    const channel = connection.createDataChannel('chat');
    channel.onopen = () => {
        console.log("channel one opened")
        channel.send("test");
    };
    await signalingChannelOne.offer(receivedSignalingServerUrl, selfPeerId, connection)
})

signalingChannelTwo.onOffer = (url, peerId, offer) => {
    // Accept data channel with signaling channel two.
    const connection = new RTCPeerConnection(configuration)
    connection.ondatachannel = (event) => {
        const channel = event.channel;
        channel.onopen = () => {
            console.log("channel two opened")
        };
        channel.onmessage = (event) => {
            console.log("channel two received message " + event.data)
        };
    };
    return connection
}

Publish package

First publish


npm publish --access public

Update


npm version patch
npm publish

Deploying signaling server to heroku

Preparation

  • Checkout this project from github.
  • Install heroku cli.

Commands


heroku create <your-heroku-account>-webrtc-signaling
git push heroku master
heroku logs -t

Example logs from HEROKU


2018-06-09T05:57:41.988484+00:00 app[web.1]: signaling server connection request from 10.43.181.164:22969
2018-06-09T05:57:42.124399+00:00 app[web.1]: signaling server handshake success: 2482c8cb6cb565a2518f7228f65f9954d44f00d20e60df3a7b3954e533578560 10.43.181.164:22969
2018-06-09T05:57:42.250803+00:00 app[web.1]: signaling server relayed message greeting : "hello" from 2482c8cb6cb565a2518f7228f65f9954d44f00d20e60df3a7b3954e533578560 10.43.181.164:22969 to 2482c8cb6cb565a2518f7228f65f9954d44f00d20e60df3a7b3954e533578560 10.43.181.164:22969
2018-06-09T05:57:42.375682+00:00 app[web.1]: signaling server disconnected: 2482c8cb6cb565a2518f7228f65f9954d44f00d20e60df3a7b3954e533578560 10.43.181.164:22969

Healt check

Signaling server provides 200 OK healthcheck_ /signaling-health-check.

Example: http://127.0.0.1:8080/signaling-health-check