How to use the @geut/discovery-swarm-webrtc function in @geut/discovery-swarm-webrtc

To help you get started, we’ve selected a few @geut/discovery-swarm-webrtc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github geut / caracara / src / p2p / swarm.js View on Github external
const initComm = async (username, key) => {
  const publicKey = key && key.length > 0 ? key : null;
  const saga = Saga(ram, publicKey, username);

  await saga.initialize();

  const sw = swarm({
    id: username,
    stream: () => {
      return saga.replicate();
    }
  });

  const discoveryKey = saga.db.discoveryKey.toString('hex');
  const signalUrls = (process.env.SIGNAL_URLS || config.SIGNAL_URLS).split(';');
  sw.join(signalhub(discoveryKey, signalUrls), webrtcOpts);

  sw.on('connection', async peer => {
    try {
      await saga.connect(peer);
    } catch (err) {
      console.log(err);
    }

@geut/discovery-swarm-webrtc

discovery-swarm for WebRTC.

MIT
Latest version published 3 years ago

Package Health Score

52 / 100
Full package analysis

Popular @geut/discovery-swarm-webrtc functions