JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 302
  • Score
    100M100P100Q82536F
  • License MIT

socket-signal through simple-websocket

Package Exports

  • socket-signal-websocket

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (socket-signal-websocket) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

socket-signal-websocket

Build Status JavaScript Style Guide standard-readme compliant

socket-signal through simple-websocket and reconnecting support

Install

$ npm install socket-signal-websocket

Usage

Server

$ npx socket-signal-websocket [--port=4000]

Client

const { SocketSignalWebsocketClient } = require('socket-signal-websocket')

// you can define multiple server urls for fallback reconnections
const client = new SocketSignalWebsocketClient([
  'ws://localhost:4000',
  'ws://localhost:4001',
  'ws://localhost:4002'
], {
  simpleWebsocket: {}, // https://github.com/feross/simple-websocket options
  reconnectingWebsocket: {}, // https://github.com/pladaria/reconnecting-websocket options
  simplePeer: {} // https://github.com/feross/simple-peer options
})

;(async () => {
  await client.open()

  client.onIncomingPeer(async (peer) => {
    if (validPeer(peer)) return
    throw new Error('invalid peer')
  })

  const peersForThatTopic = await client.join(topic)

  const remotePeer = client.connect(peersForThatTopic[0], topic)

  try {
    await remotePeer.waitForConnection()
    // SimplePeer connected
  } catch(err) {
    // SimplePeer rejected
  }
})()

Issues

🐛 If you found an issue we encourage you to report it on github. Please specify your OS and the actions to reproduce it.

Contributing

👥 Ideas and contributions to the project are welcome. You must follow this guideline.

License

MIT © A GEUT project