Skip to content

Commit f100670

Browse files
authored
Merge pull request #34 from david-macpherson/frontend_send_offer
Replaced the logic to send the offer from the frontend depending on what is sent from the signalling server
2 parents 900bcf8 + 6f96953 commit f100670

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

examples/typescript/src/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ declare var WEBSOCKET_URL: string;
1010
// Extend the MessageRecv to allow the engine version to exist as part of our config message from the signalling server
1111
class MessageExtendedConfig extends MessageRecv {
1212
peerConnectionOptions: RTCConfiguration;
13-
engineVersion: string
13+
engineVersion: string;
14+
platform: string;
15+
frontendToSendOffer: boolean;
1416
};
1517

1618
// Extend PixelStreaming to use our custom extended config that includes the engine version
1719
class ScalablePixelStreaming extends PixelStreaming {
1820
// Create a new method that retains original functionality
1921
public handleOnConfig(messageExtendedConfig: MessageExtendedConfig) {
20-
this._webRtcController.handleOnConfigMessage(messageExtendedConfig)
22+
this._webRtcController.handleOnConfigMessage(messageExtendedConfig);
2123
}
2224
};
2325

@@ -29,16 +31,15 @@ document.body.onload = function () {
2931
// make usage of WEBSOCKET_URL if it is not empty
3032
let webSocketAddress = WEBSOCKET_URL;
3133
if (webSocketAddress != "") {
32-
config.setTextSetting(TextParameters.SignallingServerUrl, webSocketAddress)
34+
config.setTextSetting(TextParameters.SignallingServerUrl, webSocketAddress);
3335
}
3436

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

38-
// Override the onConfig so we can determine if we need to send the WebRTC offer based on the engine version
39-
// If the engine version is 4.27 or not defined, the browser should send the offer. This is what the Scalable Pixel Streaming signalling server will be expecting.
40+
// Override the onConfig so we can determine if we need to send the WebRTC offer based on what is sent from the signalling server
4041
stream.webSocketController.onConfig = (messageExtendedConfig: MessageExtendedConfig) => {
41-
stream.config.setFlagEnabled(Flags.BrowserSendOffer, (messageExtendedConfig.engineVersion == "4.27" || messageExtendedConfig.engineVersion == ""));
42+
stream.config.setFlagEnabled(Flags.BrowserSendOffer, messageExtendedConfig.frontendToSendOffer);
4243
stream.handleOnConfig(messageExtendedConfig);
4344
}
4445

0 commit comments

Comments
 (0)