Skip to content

Commit ae6cd6d

Browse files
committed
i cant believe its working 😔 i think
1 parent 181a6e8 commit ae6cd6d

6 files changed

Lines changed: 1335 additions & 359 deletions

File tree

‎package-lock.json‎

Lines changed: 100 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,28 @@
1616
"@react-native-firebase/messaging": "^23.8.8",
1717
"@react-native/new-app-screen": "0.84.1",
1818
"@thaunknown/simple-peer": "^10.1.0",
19+
"buffer": "^6.0.3",
20+
"debug": "^4.4.3",
21+
"err-code": "^3.0.1",
1922
"fzstd": "^0.1.1",
23+
"get-browser-rtc": "^1.1.0",
24+
"process": "^0.11.10",
25+
"queue-microtask": "^1.2.3",
26+
"randombytes": "^2.1.0",
2027
"react": "19.2.3",
2128
"react-native": "0.84.1",
2229
"react-native-background-timer": "^2.4.1",
2330
"react-native-dotenv": "^3.4.11",
2431
"react-native-encrypted-storage": "^4.0.3",
32+
"react-native-get-random-values": "^2.0.0",
2533
"react-native-incall-manager": "^4.2.1",
2634
"react-native-safe-area-context": "^5.5.2",
2735
"react-native-track-player": "^5.0.0-alpha0-nightly-359af5a12d712d3b685530aed9b9625865a25d74",
2836
"react-native-url-polyfill": "^3.0.0",
2937
"react-native-video": "^6.19.1",
3038
"react-native-webrtc": "^124.0.7",
3139
"react-native-webview": "^13.16.1",
40+
"readable-stream": "^4.7.0",
3241
"socket.io-client": "^4.8.3",
3342
"text-encoding-polyfill": "^0.6.7"
3443
},

‎src/CallProvider.tsx‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ import {
99
} from 'react';
1010
import { useSocket, useSocketListener } from './SocketProvider';
1111
import { getUserId, getUserToken } from './EncryptedStore';
12-
import SimplePeer, { SimplePeerData } from '@thaunknown/simple-peer/lite';
12+
import SimplePeer from './SimplePeer';
1313
import inCallManager from 'react-native-incall-manager';
14-
import { mediaDevices, MediaStream } from 'react-native-webrtc';
14+
import {
15+
mediaDevices,
16+
MediaStream,
17+
RTCIceCandidate,
18+
RTCPeerConnection,
19+
RTCSessionDescription,
20+
} from 'react-native-webrtc';
1521
import notifee, {
1622
AndroidCategory,
1723
AndroidImportance,
@@ -37,7 +43,7 @@ interface UserJoinPayload {
3743
}
3844

3945
interface SignalPayload {
40-
signal: SimplePeerData;
46+
signal: any;
4147
fromUserId: string;
4248
channelId: string;
4349
}
@@ -48,14 +54,14 @@ export interface VoiceUser {
4854
userId: string;
4955
channelId: string;
5056
serverId: null | string;
51-
peer?: SimplePeer.Instance;
57+
peer?: any;
5258
connected?: boolean;
5359
}
5460

5561
export const CallProvider = (props: { children: JSX.Element }) => {
5662
const [joinedChannelId, setJoinedChannelId] = useState<string | null>(null);
5763
const [voiceUsers, setVoiceUsers] = useState<VoiceUser[]>([]);
58-
const peersRef = useRef<Map<string, SimplePeer.Instance>>(new Map());
64+
const peersRef = useRef<Map<string, any>>(new Map());
5965

6066
const appState = useRef(AppState.currentState);
6167
const interval = useRef<IntervalId>(0);
@@ -184,7 +190,7 @@ export const CallProvider = (props: { children: JSX.Element }) => {
184190
}
185191
});
186192

187-
const createPeer = (voiceUser: VoiceUser, signal?: SimplePeerData) => {
193+
const createPeer = (voiceUser: VoiceUser, signal?: any) => {
188194
const key = peerKey(voiceUser.channelId, voiceUser.userId);
189195
const existingPeer = peersRef.current.get(key);
190196

@@ -194,6 +200,11 @@ export const CallProvider = (props: { children: JSX.Element }) => {
194200
new SimplePeer({
195201
trickle: true,
196202
initiator: !signal,
203+
wrtc: {
204+
RTCPeerConnection,
205+
RTCIceCandidate,
206+
RTCSessionDescription,
207+
},
197208
stream: micStreamRef.current ?? undefined,
198209
config: {
199210
iceServers: [
@@ -230,7 +241,7 @@ export const CallProvider = (props: { children: JSX.Element }) => {
230241
});
231242
});
232243

233-
peer.on('signal', (newSignal: SimplePeerData) => {
244+
peer.on('signal', (newSignal: any) => {
234245
socket?.emit('voice:signal_send', {
235246
channelId: voiceUser.channelId,
236247
toUserId: voiceUser.userId,

0 commit comments

Comments
 (0)