diff --git a/app/mobile/src/session/Session.jsx b/app/mobile/src/session/Session.jsx
index 997d37e7..84456659 100644
--- a/app/mobile/src/session/Session.jsx
+++ b/app/mobile/src/session/Session.jsx
@@ -370,8 +370,8 @@ export function Session() {
tabBarActiveTintColor: Colors.white,
tabBarInactiveTintColor: Colors.disabled,
})}>
-
+
)}
diff --git a/app/mobile/src/session/profile/Profile.jsx b/app/mobile/src/session/profile/Profile.jsx
index 0165e059..a7822fdf 100644
--- a/app/mobile/src/session/profile/Profile.jsx
+++ b/app/mobile/src/session/profile/Profile.jsx
@@ -37,13 +37,21 @@ export function ProfileBody() {
const peer = useRef();
const stream = useRef();
const [streamUrl, setStreamUrl] = useState(null);
+ const localMediaStream = useRef();
useEffect(() => {
+
+
+console.log("WS CONNECT!!!");
+console.log("WS CONNECT!!!");
+console.log("WS CONNECT!!!");
+console.log("WS CONNECT!!!");
+console.log("WS CONNECT!!!");
+console.log("WS CONNECT!!!");
+console.log("WS CONNECT!!!");
ws.current = new WebSocket('wss://balzack.coredb.org/relay');
ws.current.onmessage = async (ev) => {
-console.log(ev.data);
-
const msg = JSON.parse(ev.data);
if (msg.candidate) {
console.log("> CANDIDATE: ", msg.candidate);
@@ -60,6 +68,8 @@ console.log(ev.data);
}
else if (msg.answer) {
console.log("> ANSWER: ", msg.answer);
+ const answer = new RTCSessionDescription( msg.answer );
+ await peer.current.setRemoteDescription( answer );
}
}
ws.current.onclose = (e) => {
@@ -89,6 +99,7 @@ console.log(ev.data);
};
peer.current = new RTCPeerConnection( peerConstraints );
+ go();
peer.current.addEventListener( 'connectionstatechange', event => {
console.log("CONNECTION STATE");
@@ -110,6 +121,7 @@ console.log(ev.data);
peer.current.addEventListener( 'negotiationneeded', event => {
console.log("ICE NEGOTIATION");
+ start();
} );
peer.current.addEventListener( 'signalingstatechange', event => {
@@ -131,6 +143,46 @@ console.log(ev.data);
}, []);
+ const go = async () => {
+
+
+ let mediaConstraints = {
+ audio: true,
+ video: {
+ frameRate: 4,
+ facingMode: 'user'
+ }
+ };
+
+console.log("GETTING MEDIA DEVICES");
+
+ localMediaStream.current = await mediaDevices.getUserMedia( mediaConstraints );
+ }
+
+const okay = async () => {
+
+ console.log("ADDING TRACKS");
+ localMediaStream.current.getTracks().forEach((track) => {
+ peer.current.addTrack( track, localMediaStream.current )
+ console.log("TRACK ADDED!!!!");
+ });
+};
+
+
+ const start = async () => {
+ let sessionConstraints = {
+ mandatory: {
+ OfferToReceiveAudio: false,
+ OfferToReceiveVideo: true,
+ VoiceActivityDetection: false,
+ }
+ };
+
+ const offer = await peer.current.createOffer( sessionConstraints );
+ await peer.current.setLocalDescription( offer );
+ ws.current.send(JSON.stringify({ offer }));
+ };
+
const logout = async () => {
Alert.alert(
"Logging Out",
@@ -241,7 +293,15 @@ console.log(ev.data);
return (
- WEBRTC
+
+ SEND
+
+
+
+
+ START
+
+