API
useWebRTC
A hook to manage outspeed’s WebRTC connection.
The useWebRTC
hook handles all the necessary logic to manage a WebRTC connection with the Outspeed’s backend.
Options
- Required
- This configuration is used by the
useWebRTC
hook to initialize local audio and video streams, set up peer connections, enable logging, and more. - Learn more about
config
here.
Returns
Init
when the component mounts andconfig
is undefined.Connecting
whenconnect
is called and the connection to the backend is in progress.Connected
when the connection to the backend is successful.Failed
if the connection to the backend fails.Disconnected
when successfully disconnected from the backend.
- A function that initiates the connection to the backend.
- A function to disconnect from the backend.
- A WebRTC data channel for sending and receiving messages.
- To send a message to the backend, use
dataChannel.send({ type: "message", data: "Hello" })
. - To listen for messages from the backend, use
dataChannel.addEventListener('message', (message) => console.log(message))
. - To remove a message listener, use
dataChannel.removeEventListener('message', onMessage)
.
- Returns the first local audio stream, or
null
if no audio track is available. - This is a reactive function that may trigger a re-render when a track is added or removed.
- Returns the first local video stream, or
null
if no video track is available. - This is a reactive function that may trigger a re-render when a track is added or removed.
- An array of remote media stream.
Resources
Was this page helpful?