Skip to content

Sample App for SimpleWebRTC including tiny backend example

License

Notifications You must be signed in to change notification settings

simplewebrtc/backend-sample-app

Repository files navigation

SimpleWebRTC Sample App with User Data Backend

This repo is provided as an example only and may not be appropriate for your use case.

You can retrieve your API key by visiting https://accounts.simplewebrtc.com.

Backend

The backend here signs a JSON object with an API Secret creating a JWT. The entirety of the backend lives here in the index.js file

Using the Backend

The backend is invoked by retrieving some JSON data from the /generateUserData route.

The result of this request is parsed as JSON and then set to the userData attribute of the App Component. See the docs for more info on how to retrieve the data from peers to use in your app.

In this example the userId key from user data is rendered in the PeerGridItem.

Running locally

  1. npm i
  2. SWRTC_API_KEY=<YOUR_API_KEY> npm run build:app
  3. SWRTC_API_SECRET=<YOUR_SECRET_KEY> npm start
  4. Go to https://localhost:5000/

Running with Docker

  1. Ensure that docker is installed on your host
  2. docker build --build-args SWRTC_API_KEY=<YOUR_API_KEY> --tag <your-tag> .
  3. docker push <your-tag>
  4. docker run -e SWRTC_API_SECRET=<YOUR_API_SECRET> <your-tag>

Note: docker run may require you to map the internal port with -p 5000:5000 or --net=host depending on your host configuration

Sound Configuration

Sound effects for peers joining/leaving, messages, and sound output testing can be configured.

Put your audio files into the /public directory, and uncomment the desired <meta /> tags in /public/index.html, setting the content attribute to the URL of the audio file:

<meta name="simplewebrtc-sound-message-receive" content="/url-of-mp3-file" />
<meta name="simplewebrtc-sound-message-send" content="/url-of-mp3-file" />
<meta name="simplewebrtc-sound-peer-enter" content="/url-of-mp3-file" />
<meta name="simplewebrtc-sound-peer-exit" content="/url-of-mp3-file" />
<meta name="simplewebrtc-sound-test-output" content="/url-of-mp3-file" />

About

Sample App for SimpleWebRTC including tiny backend example

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published