Skip to content

Commit

Permalink
Implement processAnswer
Browse files Browse the repository at this point in the history
  • Loading branch information
whitphx committed Jan 24, 2021
1 parent aa2ab49 commit 7fbf0eb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tiny_streamlit_webrtc/frontend/src/TinyWebrtc.tsx
Expand Up @@ -22,7 +22,10 @@ class TinyWebrtc extends StreamlitComponentBase<State> {
}

public componentDidUpdate = () => {
console.log("Answer: ", this.props.args["answer"])
if (this.props.args["answer"]) {
const answer = new RTCSessionDescription(this.props.args["answer"])
this.processAnswer(answer)
}
}

public render = (): ReactNode => {
Expand Down Expand Up @@ -92,6 +95,15 @@ class TinyWebrtc extends StreamlitComponentBase<State> {
})
}

private processAnswer = (answer: RTCSessionDescription) => {
if (this.pc == null) {
console.error("this.pc is not initialized yet.")
return
}

this.pc.setRemoteDescription(answer)
}

private start = () => {
const pc = this.createPeerConnection()

Expand Down

0 comments on commit 7fbf0eb

Please sign in to comment.