React
Code Template
import "./App.css";
import { ArcwareInit } from "@arcware-cloud/pixelstreaming-websdk";
import React, { useState, useRef, useEffect } from "react";
function App() {
const videoContainerRef = useRef(null);
const [arcwareApplication, setArcwareApplication] = useState(null);
const [applicationResponse, setApplicationResponse] = useState("");
const handleSendCommand = (descriptor) => {
arcwareApplication?.emitUIInteraction(descriptor);
};
useEffect(() => {
const { Config, PixelStreaming, Application } = ArcwareInit(
{
shareId: "<your-shareId-goes-here>"
},
{
initialSettings: {
StartVideoMuted: true,
AutoConnect: true,
AutoPlayVideo: true
},
settings: {
infoButton: true,
micButton: true,
audioButton: true,
fullscreenButton: true,
settingsButton: true,
connectionStrengthIcon: true
}
}
);
setArcwareApplication(Application);
Application.getApplicationResponse((response) =>
setApplicationResponse(response)
);
// Append the application's root element to the video container
if (videoContainerRef?.current) {
videoContainerRef.current.appendChild(Application.rootElement);
}
}, []);
return (
<div>
<div
ref={videoContainerRef}
style={{ width: "100vw", height: "100vh" }}
/>
<button
style={{
position: "absolute",
right: "100px",
bottom: 20,
margin: "auto",
zIndex: 9,
width: "200px"
}}
onClick={() => handleSendCommand({ test: "Send command" })}
>
Emit command to Unreal
</button>
</div>
);
}
export default App;How This Example Works
1. Initialize the WebSDK
2. Attach the Stream to the React Component
3. Receive Messages from Unreal Engine
4. Send Messages to Unreal Engine
Notes
Last updated