Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tensorworks/spstypescriptexample",
"version": "0.0.1",
"version": "0.0.2",
"description": "The typescript example for consuming the Scalable Pixel Streaming Frontend",
"main": "./src/index.ts",
"scripts": {
Expand Down Expand Up @@ -38,4 +38,4 @@
"webpack-dev-server": "^4.11.1",
"wepack-cli": "^0.0.1-security"
}
}
}
38 changes: 30 additions & 8 deletions examples/typescript/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Config, PixelStreaming, SPSApplication, TextParameters, PixelStreamingApplicationStyle} from "@tensorworks/libspsfrontend";
import { Config, PixelStreaming, SPSApplication, TextParameters, PixelStreamingApplicationStyle, MessageRecv, Flags } from "@tensorworks/libspsfrontend";

// Apply default styling from Epic Games Pixel Streaming Frontend
export const PixelStreamingApplicationStyles = new PixelStreamingApplicationStyle();
Expand All @@ -7,24 +7,46 @@ PixelStreamingApplicationStyles.applyStyleSheet();
// websocket url env
declare var WEBSOCKET_URL: string;

// Extend the MessageRecv to allow the engine version to exist as part of our config message from the signalling server
class MessageExtendedConfig extends MessageRecv {
peerConnectionOptions: RTCConfiguration;
engineVersion: string;
platform: string;
frontendToSendOffer: boolean;
};

// Extend PixelStreaming to use our custom extended config that includes the engine version
class ScalablePixelStreaming extends PixelStreaming {
// Create a new method that retains original functionality
public handleOnConfig(messageExtendedConfig: MessageExtendedConfig) {
this._webRtcController.handleOnConfigMessage(messageExtendedConfig);
}
};

document.body.onload = function () {

// Create a config object.
// Note: This config is extremely important, SPS only supports the browser sending the offer.
const config = new Config({ useUrlParams: true, initialSettings: { OfferToReceive: true, TimeoutIfIdle: true } });
// Create a config object. We default to sending the WebRTC offer from the browser as true, TimeoutIfIdle to true, AutoConnect to false and MaxReconnectAttempts to 0
const config = new Config({ useUrlParams: true, initialSettings: { OfferToReceive: true, TimeoutIfIdle: true, AutoConnect: false, MaxReconnectAttempts: 0 } });

// make usage of WEBSOCKET_URL if it is not empty
let webSocketAddress = WEBSOCKET_URL;
if(webSocketAddress != ""){
config.setTextSetting(TextParameters.SignallingServerUrl, webSocketAddress)
if (webSocketAddress != "") {
config.setTextSetting(TextParameters.SignallingServerUrl, webSocketAddress);
}

// Create stream and spsApplication instances that implement the Epic Games Pixel Streaming Frontend PixelStreaming and Application types
const stream = new PixelStreaming(config);
const stream = new ScalablePixelStreaming(config);

// Override the onConfig so we can determine if we need to send the WebRTC offer based on what is sent from the signalling server
stream.webSocketController.onConfig = (messageExtendedConfig: MessageExtendedConfig) => {
stream.config.setFlagEnabled(Flags.BrowserSendOffer, messageExtendedConfig.frontendToSendOffer);
stream.handleOnConfig(messageExtendedConfig);
}

// Create and append our application
const spsApplication = new SPSApplication({
stream,
onColorModeChanged: (isLightMode) => PixelStreamingApplicationStyles.setColorMode(isLightMode) /* Light/Dark mode support. */
});

document.body.appendChild(spsApplication.rootElement);
}
2 changes: 1 addition & 1 deletion examples/typescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"noImplicitAny": true,
"module": "es6",
"esModuleInterop": true,
"target": "es5",
"target": "ES6",
"moduleResolution": "node",
"sourceMap": false,
"allowJs": true,
Expand Down
21 changes: 11 additions & 10 deletions library/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions library/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tensorworks/libspsfrontend",
"version": "0.3.3",
"version": "0.3.4",
"description": "The Scalable Pixel Streaming Frontend Library consuming Epic Games' Pixel Streaming Frontend",
"main": "dist/libspsfrontend.min.js",
"module": "dist/libspsfrontend.esm.js",
Expand All @@ -15,7 +15,7 @@
"license": "MIT",
"dependencies": {
"@epicgames-ps/lib-pixelstreamingfrontend-ue5.2": "^0.5.1",
"@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2": "^0.4.0"
"@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2": "^0.4.1"
},
"devDependencies": {
"css-loader": "^6.7.3",
Expand Down