diff --git a/examples/typescript/package.json b/examples/typescript/package.json index a04e94c8..8f8162db 100644 --- a/examples/typescript/package.json +++ b/examples/typescript/package.json @@ -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": { @@ -38,4 +38,4 @@ "webpack-dev-server": "^4.11.1", "wepack-cli": "^0.0.1-security" } -} +} \ No newline at end of file diff --git a/examples/typescript/src/index.ts b/examples/typescript/src/index.ts index e2337471..d36fb40c 100644 --- a/examples/typescript/src/index.ts +++ b/examples/typescript/src/index.ts @@ -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(); @@ -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); } \ No newline at end of file diff --git a/examples/typescript/tsconfig.json b/examples/typescript/tsconfig.json index 32cb2238..c9623293 100644 --- a/examples/typescript/tsconfig.json +++ b/examples/typescript/tsconfig.json @@ -4,7 +4,7 @@ "noImplicitAny": true, "module": "es6", "esModuleInterop": true, - "target": "es5", + "target": "ES6", "moduleResolution": "node", "sourceMap": false, "allowJs": true, diff --git a/library/package-lock.json b/library/package-lock.json index 68e57307..5f7088d4 100644 --- a/library/package-lock.json +++ b/library/package-lock.json @@ -1,16 +1,16 @@ { "name": "@tensorworks/libspsfrontend", - "version": "0.3.2", + "version": "0.3.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@tensorworks/libspsfrontend", - "version": "0.3.2", + "version": "0.3.3", "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", @@ -53,16 +53,17 @@ } }, "node_modules/@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2/-/lib-pixelstreamingfrontend-ui-ue5.2-0.4.0.tgz", - "integrity": "sha512-WwIUMMMxRDbo+LTt/t3b24qNhTX4d4TuWoj4Ynw37fX8SHLFvJ++9U0ByP3bRxyw9scRBNTVtCZ/6kZIzJV2fQ==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2/-/lib-pixelstreamingfrontend-ui-ue5.2-0.4.1.tgz", + "integrity": "sha512-GXwB4/LS2fcVyfTAHe6Ma90+Z+oxNIIiwowe0S5ItgsGn2DPo1KwhDw7AbIsbqgtJDntKoofuzrtcdU6lG4RNw==", + "license": "MIT", "dependencies": { "jss": "^10.9.2", "jss-plugin-camel-case": "^10.9.2", "jss-plugin-global": "^10.9.2" }, "peerDependencies": { - "@epicgames-ps/lib-pixelstreamingfrontend-ue5.2": "^0.5.0" + "@epicgames-ps/lib-pixelstreamingfrontend-ue5.2": "^0.5.1" } }, "node_modules/@jridgewell/gen-mapping": { @@ -4333,9 +4334,9 @@ } }, "@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2/-/lib-pixelstreamingfrontend-ui-ue5.2-0.4.0.tgz", - "integrity": "sha512-WwIUMMMxRDbo+LTt/t3b24qNhTX4d4TuWoj4Ynw37fX8SHLFvJ++9U0ByP3bRxyw9scRBNTVtCZ/6kZIzJV2fQ==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@epicgames-ps/lib-pixelstreamingfrontend-ui-ue5.2/-/lib-pixelstreamingfrontend-ui-ue5.2-0.4.1.tgz", + "integrity": "sha512-GXwB4/LS2fcVyfTAHe6Ma90+Z+oxNIIiwowe0S5ItgsGn2DPo1KwhDw7AbIsbqgtJDntKoofuzrtcdU6lG4RNw==", "requires": { "jss": "^10.9.2", "jss-plugin-camel-case": "^10.9.2", diff --git a/library/package.json b/library/package.json index ac3cd55d..bf895eb4 100644 --- a/library/package.json +++ b/library/package.json @@ -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", @@ -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",