You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
does react-native-peerjs works and is it useable ?
im working with this now and every thing works except that call response fires no event . and its event count is 0 ,
my code is good and simple as docs everywhere .
my react native code :
React.useEffect(()=>{socket.clientSocket.on("connect",()=>{console.log("----- - - --- - - socket connection")});conststart=async()=>{lets;try{s=awaitmediaDevices.getUserMedia({video: true});peer.peerServer.on("open",(peerId)=>{socket.clientSocket.emit("join-room",{peerId ,userId: pageStates.userId,roomId: pageStates.roomId});});// user enteredsocket.clientSocket.on("a-user-entered",({newUserPeerId , newUserId})=>{constcall=peer.peerServer.call(newUserPeerId,s);call.on("stream",(remoteVideoStream)=>{if(remoteVideoStream){console.log("stream",remoteVideoStream)}});});peer.peerServer.on("call",(call)=>{call.answer(s);call.on("stream",(remoteS)=>{console.log("and we got "+remoteS)});});}};start();},[])
I have managed to make it work, and I'm not using 'react-native-peerjs'. I have added patch you can found here webrtcHacks/adapter#1129 . It can be applied with patch-package. And I have ended up listening for an open event like this.
if (!dataConn.open) {
await new Promise<void>(resolve => {
dataConn.on('open', resolve);
// FIXME: no open event fired before listeners ready
const interval = setInterval(() => {
const state = dataConn.dataChannel?.readyState;
console.log('----', state);
if (state === 'open') {
clearInterval(interval);
if (!dataConn.open) {
(dataConn as any)._open = true;
dataConn.emit('open');
}
}
}, 50);
});
}
Looks like peerjs too late in subscribing to open, and it's just not handled right away. But I did not checked calling yet
does react-native-peerjs works and is it useable ?
im working with this now and every thing works except that
call response fires no event
. and its event count is 0 ,my code is good and simple as docs everywhere .
my react native code :
and also my call response log is :
{"_events": {}, "_eventsCount": 0, "_localStream": {"_reactTag": "6b63bf42-2383-45cc-9458-2f20927dbb8c", "_tracks": [[MediaStreamTrack]], "active": true, "id": "6b63bf42-2383-45cc-9458-2f20927dbb8c"}, "_negotiator": {"connection": [Circular]}, "_open": false, "connectionId": "mc_20pq73qhn40i", "metadata": undefined, "options": {"_stream": {"_reactTag": "6b63bf42-2383-45cc-9458-2f20927dbb8c", "_tracks": [Array], "active": true, "id": "6b63bf42-2383-45cc-9458-2f20927dbb8c"}}, "peer": "a524dd90-c02e-4378-97ef-f364b502ee07", "peerConnection": {"_pcId": 1, "_remoteStreams": Map {}, "_transceivers": [], "connectionState": "new", "iceConnectionState": "new", "iceGatheringState": "new", "localDescription": null, "onaddstream": [Function anonymous], "remoteDescription": null, "signalingState": "stable"}, "provider": {"_api": {"_options": [Object]}, "_connections": Map {"a524dd90-c02e-4378-97ef-f364b502ee07" => [Array]}, "_destroyed": false, "_disconnected": false, "_events": {"call": [r], "discounnect": [r], "error": [r], "open": [r]}, "_eventsCount": 4, "_id": "0cc522b5-04d5-4b18-aa8b-30c83900373b", "_lastServerId": "0cc522b5-04d5-4b18-aa8b-30c83900373b", "_lostMessages": Map {}, "_open": true, "_options": {"config": [Object], "debug": 0, "host": "node2.bonyadonline.com", "key": "peerjs", "path": "/peer-server/", "port": 443, "secure": true, "token": "106ukcqolqv"}, "_socket": {"_baseUrl": "wss://node2.bonyadonline.com:443/peer-server/peerjs?key=peerjs", "_disconnected": false, "_events": [Object], "_eventsCount": 4, "_id": "0cc522b5-04d5-4b18-aa8b-30c83900373b", "_messagesQueue": [Array], "_socket": [WebSocket], "_wsPingTimer": 46, "pingInterval": 5000}}}
The text was updated successfully, but these errors were encountered: