Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Answer created only on Hot Reload #939

Open
knuckledump opened this issue Jul 4, 2024 · 0 comments
Open

Answer created only on Hot Reload #939

knuckledump opened this issue Jul 4, 2024 · 0 comments

Comments

@knuckledump
Copy link

Hey, I am working on a live chat app between two people however the video streaming only works when I do a hot reload on my react code file.
The issue is the offer is sent and recieved however the answer is not created and sent back
Here is my code (the same code is used for both clients the only difference is the "caller" variable is set to true for one client)

const localVideoRef = useRef(null);
const remoteVideoRef = useRef(null);

const [localStream, setLocalStream] = useState();
const [isMuted, setIsMuted] = useState(false);
const [isVideoOff, setIsVideoOff] = useState(false);

const peer = new SimplePeer({
initiator : caller,
trickle : false,
})

const getLocalStream = async () => {

const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true })
peer.addStream(stream)
setLocalStream(stream);
localVideoRef.current.srcObject = stream;

};

useEffect(() => {

SIGNALRCONNECTION.getConnection().on(ReceiveSignal/${callId}, data => {
console.log("Recieved: ", JSON.parse(data));
peer.signal(JSON.parse(data))
})

peer.on('signal', data => {
console.log("Send:", data)
SIGNALRCONNECTION.getConnection().invoke("SendSignal", callId, JSON.stringify(data));
})

peer.on('stream', stream => {
const remoteStream = stream;
remoteVideoRef.current.srcObject = remoteStream;
})

getLocalStream()

}, []);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant