New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-pixel-streaming

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package version was removed
This package version has been unpublished, mostly likely due to security reasons

react-pixel-streaming

With Pixel Streaming, you run a packaged Unreal Engine application on a desktop PC or a server in the cloud, along with a small stack of web services that are included with the Unreal Engine.

unpublished
Source
npmnpm
Version
0.0.1
Version published
Weekly downloads
8
-11.11%
Maintainers
1
Weekly downloads
 
Created
Source

PixelStreaming for ReactJS

Library for launching the player for Pixel Streaming (Unreal Engine v.5)

Connects to running STUN and TURN Servers.

Demo: https://unrealos.com/streams/demo/

CodeSandBox https://codesandbox.io/s/pixel-streaming-r4wvd

Installation

npm install pixel-streaming
# or
yarn add pixel-streaming

Usage

import React from 'react';

// libs
import PixelStreaming, {DebugData} from 'pixel-streaming';

function App() {
  const refPixelStreaming = React.useRef(null)
  const [serverData, setServerData] = React.useState({host: 'http://127.0.0.1', port: 80})

  const actionClass = new class {
    constructor() {
      this.ref = refPixelStreaming.current
    }

    _emit(type, value, verification_id=undefined) {
      this.ref.emit({type, value, verification_id})
    }

    emitTestCommand(value) {
      this._emit('test_command_type', value)
    }
  }

  const renderForm = ({state, initConnection}) => {
    if(state.loaded) {
      return (
        <button onClick={() => actionClass.emitTestCommand(11)}>
          Test command
        </button>
      )
    }

    return (
      <form onSubmit={(event) => {
        event.preventDefault()
        event.stopPropagation()

        initConnection()
      }}>
        <input type="text" placeholder="http://127.0.0.1" value={serverData.host} onChange={(event) => setServerData(c => ({
          ...c, host: event.target.value
        }))} />
        <input style={{width: 50}} type="number" placeholder="80" value={serverData.port} onChange={(event) => setServerData(c => ({
          ...c, port: event.target.value
        }))} />
        <button type="submit">Connect</button>
      </form>
    )
  }

  return (
    <div>

      <PixelStreaming
        ref={refPixelStreaming}

        onLoad={(payload) => {
          console.warn('loaded', payload);
        }}
        onConnect={() => {
          console.warn('connected');
        }}
        onRestart={() => {
          // ...
        }}
        onError={(payload) => {
          console.error('error', payload);
        }}
        onClose={(payload) => {
          console.error('closed', payload);
        }}
        onCallback={(payload => {
          console.warn('callback', payload);
        })}
        onProgress={(payload) => {
          console.warn('progress', payload);
        }}
        secondsToStart={300}
        autoConnect={false}
        host={serverData.host}
        port={serverData.port} >
        {({state, initConnection}) => (
          <div style={{padding: 30}}>

            {renderForm({state, initConnection})}

            {<pre>{JSON.stringify(state, null, 4)}</pre>}

            <DebugData
              show
              style={{width: 300, backgroundColor: 'rgba(0,0,0,.2)'}}
            />

          </div>
        )}
      </PixelStreaming>

    </div>
  )
}

export default App

Props

PropDescription
onProgressfunction — Return progress in percentage based on secondsToStart
onRestartfunction — Called when the stream is restarted
onLoadfunction — When the stream started
secondsToStartint — Approximate stream start time in seconds
hostString host to url with signal server.
If host starts wihhttps then it will be used wss 
If starts with http then will be used ws
Example: https://uuid1234567890.streamdomain.com
portint — port of signal server, default 80
childrenfunction — Children element with inner data ({({state}) => (...)})
refReference to object

Reference object data

refPixelStreaming.current.state
VariableDefaultDescription
aggregated_statsfalse
callback_callerfalse
callback_loadingfalse
closedfalse
connectfalse
errorfalse
last_interactionnull
loadedfalse
mouse_movingfalse
quality_speedfalse
resolution_multiplier1.5
stream_configfalse
users_count0
window_size{width: 0, height: 0}
refPixelStreaming.current.emit(...)
refPixelStreaming.current.emit({
 type: 'string', //key of command
 value: 0, //string, bool, number
 verification_id: undefined, //server response with execute command by verification id
})

Attention!

  • React v.17.0.2

  • Apply style pointerEvents: 'none' to all JSX elements that overlap the stream.

Built With

Use with pleasure!

UnrealOS.com Team

Keywords

react

FAQs

Package last updated on 20 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts