WebRTC React mixins for real-time communication in React components using PeerJS library. Read more on how PeerJS works.
This is WIP, check Todo. More features will come soon.
This package requires webpack
and babel-loader
. Check webpack.config.js
for build configuration.
npm install react-webrtc
This mixin extends React component with API call functions and event handling interface.
Also component's state will be populated with rtc_id
property, which is a session ID for current peer.
.connect(id)
— connect to remote peer by itsid
..send(data)
— send data to all connected peers..close(id)
— close all connections or specified byid
.
._onData (data) {...}
— handle incoming data.._onInbound (id) {...}
— handle inbound connection.._onInboundClose (id) {...}
— handle closed inbound connection.._onOutbound (id) {...}
— handle outbound connection.._onOutboundClose (id) {...}
— handle closed outbound connection.
Check examples
directory.
npm install && npm start
Go to localhost:3000/examples/
- DataChannel
- MediaStream