Skip to content

Commit

Permalink
override the stream disconnect event and fire off our own webrtc disc…
Browse files Browse the repository at this point in the history
…onnect that always allows a reconnect. also fix some grammar issues
  • Loading branch information
dan-tw committed Jul 10, 2024
1 parent bea8437 commit 71d7062
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion 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, MessageRecv, Flags } from "@tensorworks/libspsfrontend";
import { Config, PixelStreaming, SPSApplication, TextParameters, PixelStreamingApplicationStyle, MessageRecv, Flags, WebRtcDisconnectedEvent } from "@tensorworks/libspsfrontend";

// Apply default styling from Epic Games Pixel Streaming Frontend
export const PixelStreamingApplicationStyles = new PixelStreamingApplicationStyle();
Expand Down Expand Up @@ -34,6 +34,24 @@ document.body.onload = function () {
stream.handleOnConfig(messageExtendedConfig);
}

// override the _onDisconnect function to intercept webrtc disconnect events
// and modify how the event is fired by always showing a click to reconnect overlay.
// we also add a full stop to the AFK message.
stream._onDisconnect = function (eventString: string) {

// check if the eventString coming in is the inactivity string and add a full stop
if (eventString == "You have been disconnected due to inactivity") {
eventString += "."
}

this._eventEmitter.dispatchEvent(
new WebRtcDisconnectedEvent({
eventString: eventString,
allowClickToReconnect: true
})
);
}

// Create and append our application
const spsApplication = new SPSApplication({
stream,
Expand Down
2 changes: 1 addition & 1 deletion library/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export { MessageSendTypes, MessageStats } from "./Messages";
export { MessageAuthRequest, InstanceState, MessageInstanceState, MessageAuthResponseOutcomeType, MessageAuthResponse, MessageRequestInstance, SPSSignalling } from "./SignallingExtension";

// Epic Games Pixel Streaming Frontend exports
export { WebRtcPlayerController } from '@epicgames-ps/lib-pixelstreamingfrontend-ue5.4';
export { WebRtcPlayerController, WebRtcDisconnectedEvent } from '@epicgames-ps/lib-pixelstreamingfrontend-ue5.4';
export { WebXRController } from '@epicgames-ps/lib-pixelstreamingfrontend-ue5.4';
export { Config, ControlSchemeType, Flags, NumericParameters, TextParameters, OptionParameters, FlagsIds, NumericParametersIds, TextParametersIds, OptionParametersIds, AllSettings } from '@epicgames-ps/lib-pixelstreamingfrontend-ue5.4';
export { SettingBase } from '@epicgames-ps/lib-pixelstreamingfrontend-ue5.4';
Expand Down

0 comments on commit 71d7062

Please sign in to comment.