1.7.0 • Published 3 years ago

@rtcweb/server v1.7.0

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
3 years ago

@rtcweb/server

Dependency Status NPM version Downloads Node version Snyk Vulnerabilities for GitHub Repo (Specific Manifest) NPM

Real-time client/server communication over UDP using WebRTC and Node.js.

This framework fits perfectly with your next HTML5 real-time multiplayer games or chat app.

Read the documentation for more information.

Install

npm install @rtcweb/server

How to use

const geckos = require('@rtcweb/server').default;
// or with es6
import geckos from '@rtcweb/server';

const io = geckos();

io.listen();

io.onConnection((channel) => {
  channel.onDisconnect(() => {
    console.log(`${channel.id} got disconnected`);
  });

  channel.on('chat message', (data) => {
    console.log(`got ${data} from "chat message"`);
    // emit the "chat message" data to all channels in the same room
    io.room(channel.roomId).emit('chat message', data);
  });
});