# peer-stream **Repository Path**: CodeLyk/peer-stream ## Basic Information - **Project Name**: peer-stream - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-10-13 - **Last Updated**: 2024-11-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # UE5 Pixel Streaming SDK [中文](README-zh.md) [English](README.md) Compared to EpicGame's heavily-designed SDK for Pixel Streaming, peer-stream.js is a lightweight WebRTC library with 0 dependency, containing a frontend component (using WebComponents API), along with a signaling server (using NodeJS). - peer-stream.js: browser SDK for player. - signal.js: node.js signaling server. - .signal.js: signal.js with env variables. - test.html: browser web page. ## Demo ```s # install WebSocket npm install ws@8.5.0 # start Signaling Server node .signal.js # start packaged UE5 start path/to/UE5.exe -PixelStreamingURL="ws://localhost:88" # visit webpage start http://localhost:88/test.html ``` ## Env Variables for signal.js | env | type | default | usage | | ------------- | -------- | --------- | ------------------------------------------------------------------- | | PORT | number | 88 | WebSocket/HTTP port for player & UE5 | | UE5_* | string[] | [] | run command when player connected (UE5 auto start) | | one2one | bool | false | one-to-one mapping for player & UE5 | | auth | string | '' | HTTP Basic Auth username:password | | limit | number | +Infinity | limit max number of players connected | | throttle | bool | false | WebSocket throttle, prevent frequent reconnection | | exeUeCoolTime | number | 60 | Time interval between starting the same UE instance again next time | | preload | number | 1 | Number of pre started UE instances | ### Load Balance `signal.js` accept multi UE5 & player connections, where each UE5 maps to multi-players with load-balancing. Turn `one2one` on to keep one-to-one mapping. Provide `UE5_*` to start UE5 automatically. More detailed example in `.signal.js`. ## Unreal Engine enable the plugin: ```s Plugins > Built-In > Graphics > Pixel Streaming > Enabled Editor Preferences > Level Editor > Play > Additional Launch Parameters start path/to/UE5.exe -{key}={value} ``` common startup options: ```s -PixelStreamingURL="ws://localhost:88" -RenderOffScreen -Unattended -GraphicsAdapter=0 -ForceRes -ResX=1280 -ResY=720 -PixelStreamingWebRTCFps=30 -Windowed -AudioMixer -AllowPixelStreamingCommands -PixelStreamingEncoderRateControl=VBR ``` ## peer-stream.js HTML: ```html ``` or JavaScript: ```html ``` ### Messages sending messages: ```js // object will be JSON.stringify() ps.emitMessage(msg: string | object); ``` receiving messages: ```js ps.addEventListener("message", e => { // JSON.parse(e.detail) }); ``` ## Requirement - Google Chrome 90+ - Unreal Engine 5.0.3 - NodeJS 14+ - npm/ws 8.0+ ## © MIT License Copyright (c) 2020-2022 XOSG Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.