React

import React, { useRef, useEffect, useState } from 'react';
import { WebRTCClient } from '@arcware/webrtc-plugin';

export const VideoComponent = () => {
  const sizeContainerRef = useRef(null);
  const videoContainerRef = useRef(null);
  const videoRef = useRef(null);
  const audioRef = useRef(null);
  const [webRTCclient, setWebRTCclient] = useState(null);
  const [unrealApplicationResponse, setUnrealApplicationResponse] = useState<string>("");


  useEffect(() => {
    const newWebRTC = WebRTCClient ({
      address: 'wss://signalling-client.ragnarok.arcware.cloud/',
      shareId: 'share-afedf133-571e-48bb-85f7-38a62e1ffb4',
      settings: { /* object with settings */ },
      playOverlay: false,
      loader: (val) => { /* handle loader */ },
      applicationResponse: (response) => {
        setUnrealApplicationResponse(response);
      },
      sizeContainer: sizeContainerRef.current,
      container: videoContainerRef.current,
      videoRef: videoRef.current,
      audioRef: audioRef.current
    });
    setWebRTCclient(newWebRTC);
  }, []);
  
  console.log('unrealApplicationResponse', unrealApplicationResponse);

  return (
    <div ref={sizeContainerRef}>
      <div ref={videoContainerRef}>
        <video ref={videoRef} />
        <audio ref={audioRef} />
      </div>
    </div>
  );
};

Last updated