Simple-peer: react native

Created on 29 Nov 2016  路  14Comments  路  Source: feross/simple-peer

more of a feature - any chance to make it work with react-native?

All 14 comments

update: i was able to run it with react-native on android and ios. the main change is using https://github.com/oney/react-native-webrtc instead of get-browser-rtc for _wrtc

another change is using the built in streams instead of the events (can't compile on react)

var stream = require('events');
inherits(Peer, stream.EventEmitter)

another update is using require("crypto").randomBytes(20).toString('hex') instead of randombytes as it's deprecated.

i might submit a PR if there's enough interest

the main change is using https://github.com/oney/react-native-webrtc instead of get-browser-rtc for _wrtc

This doesn't require a change to the library. Just pass in your own wrtc option to the constructor.

another change is using the built in streams instead of the events (can't compile on react)

I don't understand what you mean. Can you explain further?

another update is using require("crypto").randomBytes(20).toString('hex') instead of randombytes as it's deprecated.

Where did you read that randombytes is deprecated? We can't do require('crypto') as that will bloat the browser build with the whole crypto dependency.

FYI to Google searchers: I'm successfully using simple-peer with https://www.npmjs.com/package/rn-nodeify using this CLI script: rn-nodeify --install buffer,crypto,stream,util,process,vm --hack

@sagivo Hi !

How did you use react-native-webrtc with this module ? I've this (logic) error :

10-04 11:14:01.250 29070 32228 I ReactNativeJS: 'Error', { [Error: Secure random number generation is not supported by this browser.

And my config is :

const WebRTC = require('react-native-webrtc');

const pc = new SimplePeer({
  initiator: true,
  wrtc: WebRTC
});

@stephane-r Did you get it working? How did you pass react-native-webrtc to SimplePeer?

Hi @petermercy

Yes, finaly use react-native-webrtc :) But since 2018, maybe simple-peer work on react-native now ?

For those referencing this in future: React-native-webrtc as of now supports an older version of WebRTC that apparently is not compatible with simple-peer, at least partly because of lack of support for addTrack(). https://github.com/feross/simple-peer/pull/448 suggests the npm module Adapter may be a solution, but it seems browser/node-specific in the way it shims addTrack(). I don't know of any solution at this point in making react-native-webrtc work with simple-peer.

Is this the same as of now ? with latest reac-native-webrtc

@nikpakar It looks like react-native-webrtc only supports M75. I believe that's what they were supporting when I last tried a few months ago. From their commit history, it looks like the only change since has been a documentation change. So I very much doubt it'll work now - but if you find otherwise, please let me know!

Can i run a simple video calling using simple peer on react-native. Is there any way or sample code available.

@petermercy https://github.com/react-native-webrtc/react-native-webrtc/releases if now uses M84 , @feross any way we can't get it working for react native now?

ERROR:

[Error: No WebRTC support: Not a supported browser]

fixed!

@ahmetozalp when was this fixed I don't see an update to either package

Was this page helpful?
0 / 5 - 0 ratings