Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Review changes #481

Merged
merged 7 commits into from
Jan 31, 2024
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
80 changes: 61 additions & 19 deletions Common/package-lock.json

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

8 changes: 5 additions & 3 deletions Common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"version": "0.0.8",
"description": "Common utilities library for Unreal Engine 5.5 Pixel Streaming",
"main": "build/commonjs/pixelstreamingcommon.js",
"module": "build/es2015/pixelstreamingcommon.js",
"module": "build/esm/pixelstreamingcommon.js",
"types": "build/types/pixelstreamingcommon.d.ts",
"sideEffects": false,
"scripts": {
"build_proto": "npx protoc --ts_out src/Messages --proto_path protobuf protobuf/signalling_messages.proto",
"compile": "rimraf ./build && tsc --module es2015 --outDir build/es2015 && tsc --module commonjs --outDir build/commonjs --declaration --declarationDir build/types",
"compile": "rimraf ./build && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json",
"build": "npm run build_proto && npm run compile",
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
Expand All @@ -35,6 +35,8 @@
"access": "public"
},
"dependencies": {
"@protobuf-ts/plugin": "^2.9.3"
"@protobuf-ts/plugin": "^2.9.3",
"@types/ws": "^8.5.10",
"ws": "^8.16.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,31 @@ export class SignallingProtocol {
private transport: ITransport;

/**
* Listen on this emitter for transport events, open, close, error.
* Listen on this emitter for transport events.
*
* Events emitted:
* open:
* Emitted when the transport connection opens and is ready to handle messages.
*
* error:
* Emitted when there is an error on the transport has an error and must close.
*
* close:
* Emitted when the transport connection closes and can no longer send or
* receive messages. Will also be emitted after an error.
*
* message:
* Emitted any time a message is received by the transport. Listen on this if
* you wish to capture all messages, rather than specific messages on
* 'messageHandlers'.
*/
transportEvents: EventEmitter;

/**
* Listen on this emitter for messages. Message type is the name of the event to listen for.
*
* Example:
* messageHandlers.addListener('config', (message: Messages.config) => console.log(`Got a config message: ${message}`)));
*/
messageHandlers: EventEmitter;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
// Copyright Epic Games, Inc. All Rights Reserved.

import { ITransport, BaseMessage } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5';
import { ITransport } from './ITransport';
import { BaseMessage } from '../Messages/base_message';
import WebSocket from 'ws';
import { EventEmitter } from 'events';

/**
* An implementation of WebSocketTransport from pixelstreamingcommon that supports commonjs websockets
* An implementation of WebSocketTransport from pixelstreamingcommon that supports node.js websockets
* This is needed because of the slight differences between the 'ws' node.js package and the websockets
* supported in the browsers.
* If you are using this code in a browser use 'WebSocketTransport' instead.
*/
export class WebSocketTransportCJS implements ITransport {
export class WebSocketTransportNJS implements ITransport {
WS_OPEN_STATE = 1;
webSocket: WebSocket;
events: EventEmitter;
Expand Down
3 changes: 2 additions & 1 deletion Common/src/pixelstreamingcommon.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export { Logger } from './Logger/Logger';
export { ITransport } from './Transport/ITransport';
export { WebSocketTransport } from './Transport/WebSocketTransport';
export { SignallingProtocol } from './WebSockets/SignallingProtocol';
export { WebSocketTransportNJS } from './Transport/WebSocketTransportNJS';
export { SignallingProtocol } from './Protocol/SignallingProtocol';
export { IMessageType } from "@protobuf-ts/runtime";
export { BaseMessage } from './Messages/base_message';
export { MessageRegistry } from './Messages/message_registry';
Expand Down
11 changes: 11 additions & 0 deletions Common/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"noImplicitAny": true,
"esModuleInterop": true,
"target": "ES6",
"moduleResolution": "node",
"sourceMap": true,
"allowJs": true
},
"include": ["./src/*.ts"],
}
9 changes: 9 additions & 0 deletions Common/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "./build/commonjs",
"module": "commonjs",
"declaration": true,
"declarationDir": "./build/types"
}
}
7 changes: 7 additions & 0 deletions Common/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "./build/esm",
"module": "es2015"
}
}
25 changes: 0 additions & 25 deletions Common/tsconfig.json

This file was deleted.

4 changes: 2 additions & 2 deletions Frontend/library/src/WebRtcPlayer/WebRtcPlayerController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ export class WebRtcPlayerController {
maxBitrateBps: 1000 * this.config.getNumericSettingValue(NumericParameters.WebRTCMaxBitrate)
};

this.protocol.sendWebRtcOffer(MessageHelpers.createMessage(Messages.offer, extraParams));
this.protocol.sendWebRtcOffer(extraParams);
}

/**
Expand All @@ -1630,7 +1630,7 @@ export class WebRtcPlayerController {
maxBitrateBps: 1000 * this.config.getNumericSettingValue(NumericParameters.WebRTCMaxBitrate)
};

this.protocol.sendWebRtcOffer(MessageHelpers.createMessage(Messages.answer, extraParams));
this.protocol.sendWebRtcAnswer(extraParams);

if (this.isUsingSFU) {
this.protocol.sendWebRtcDatachannelRequest();
Expand Down
13 changes: 9 additions & 4 deletions SS_Test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
FROM node:18.17.0 as builder

COPY SS_Test/package*.json /SignallingTester/SS_Test/
COPY Common/protobuf/signalling_messages.proto /SignallingTester/Common/protobuf/signalling_messages.proto
WORKDIR /SignallingTester

WORKDIR /SignallingTester/SS_Test
COPY Common/ Common
COPY SS_Test/ SS_Test

WORKDIR /SignallingTester/Common

RUN npm ci
RUN npm run build

COPY SS_Test/. .
WORKDIR /SignallingTester/SS_Test

RUN npm ci
RUN npm link ../Common
RUN npm run build

USER node
Expand Down
4 changes: 2 additions & 2 deletions SS_Test/src/signalling_tester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { IMessageType,
BaseMessage,
MessageRegistry,
MessageHelpers,
WebSocketTransportNJS,
SignallingProtocol } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5';
import { WebSocketTransportCJS } from './WebSocketTransportCJS';
import WebSocket from 'ws';

export interface ExpectedMessage {
Expand Down Expand Up @@ -157,7 +157,7 @@ export class SignallingConnection {
this.failedCallback = (connection, unsatisfiedExpects, unhandledEvents) => {};
this.processTimer = null;

this.protocol = new SignallingProtocol(new WebSocketTransportCJS());
this.protocol = new SignallingProtocol(new WebSocketTransportNJS());
this.protocol.transportEvents.addListener("open", event => this.onConnectionOpen(event));
this.protocol.transportEvents.addListener("error", event => this.onConnectionError(event));
this.protocol.transportEvents.addListener("close", event => this.onConnectionClose(event));
Expand Down
Loading