Aucune description

Jairo 0f11761784 readme il y a 6 ans
dist 66862d8aba no regeneratorRuntime il y a 6 ans
.gitignore 88e062dc33 dont ignore dist il y a 6 ans
LICENSE fc7c88d3e3 Update LICENSE il y a 10 ans
README.md 0f11761784 readme il y a 6 ans
index.js d859315a46 v2 il y a 6 ans
package.json 66862d8aba no regeneratorRuntime il y a 6 ans
yarn.lock d859315a46 v2 il y a 6 ans

README.md

PeerJS: Simple peer-to-peer with WebRTC

https://t.me/peerjs

Backers on Open Collective Sponsors on Open Collective

PeerJS provides a complete, configurable, and easy-to-use peer-to-peer API built on top of WebRTC, supporting both data channels and media streams.

It uses the concept of room, you can only connect to rooms, if you want to speak with someone, you both join to the same room. If you want to speak with multiple people, everyone join to the same room.

A room has one type (audio, video, data) and it cannot change, but you can join to as many rooms as you want.


v2 Roadmap:

  • Disconnections
  • Allow configurate custom MQTT server
  • Test joining to multiple rooms
  • Mute/unmute audio

Install

  yarn add peers/peerjs#v2.0.0

Example

import Peer from 'peerjs'

const p = new Peer("Random room ID", {
  mode: 'video', // 'audio' for audio only; 'data' for DataChannel
  onRemoteStream: rs => {
    document.querySelector('#remote_vid').srcObject = rs
  },
  onLocalStream: ls => {
    document.querySelector('#local_vid').srcObject = ls
  },
  onDataStream: ds => {
    ds.onmessage = m => {
      console.log('Got message', m)
    }

    setTimeout(() => {
      ds.send('hello')
    }, 3000)
  }
})

// unpause video send
document.querySelector('#en').onclick = () => {
  p.video(true)
}
// pause video send
document.querySelector('#di').onclick = () => {
  p.video(false)
}


Contributors

This project exists thanks to all the people who contribute. [Contribute].

Backers

Thank you to all our backers! [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

License

PeerJS is licensed under the MIT License.