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

Commit

Permalink
Fixing up signalling tester
Browse files Browse the repository at this point in the history
  • Loading branch information
mcottontensor committed Feb 28, 2024
1 parent 178ffc5 commit c51db16
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
5 changes: 2 additions & 3 deletions SS_Test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ async function main(): Promise<void> {
streamer.addEventExpect('open', (event: WebSocket.Event) => {});
streamer.addExpect(Messages.config, (msg: Messages.config) => {});
streamer.addExpect(Messages.identify, (msg: Messages.identify) => streamer.sendMessage(Messages.endpointId, { id: config.streamerId }));
streamer.addExpect(Messages.endpointIdConfirm, (event: Messages.endpointIdConfirm) => {});

let playerId: string | null = null;
let player: SignallingConnection = context.newConnection('Player', config.playerURL);

player.addEventExpect('open', (event: WebSocket.Event) => {});
player.addExpect(Messages.config, (msg: Messages.config) => {});
player.addExpect(Messages.playerCount, (msg: Messages.playerCount) => {});

if (!await context.validateStep(3000, [streamer, player])) {
onFailedPhase('initial connection', context);
Expand Down Expand Up @@ -118,8 +118,7 @@ async function main(): Promise<void> {

player = context.newConnection('Player', config.playerURL);
player.addEventExpect('open', (event: WebSocket.Event) => {});
player.addExpect(Messages.config, (msg: Messages.config) => {});
player.addExpect(Messages.playerCount, (msg: Messages.playerCount) => player.sendMessage(Messages.listStreamers));
player.addExpect(Messages.config, (msg: Messages.config) => player.sendMessage(Messages.listStreamers));
player.addExpect(Messages.streamerList, (msg: Messages.streamerList) => player.sendMessage(Messages.subscribe, { streamerId: config.streamerId }));
streamer.addExpect(Messages.playerConnected, (msg: Messages.playerConnected) => {
playerId = msg.playerId!;
Expand Down
18 changes: 10 additions & 8 deletions SS_Test/src/signalling_tester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ export class TestContext {
const errors = unhandledEvents.filter((event) => event.type == 'error') as ErrorEvent[];

for (const expected of unsatisfiedMessages) {
this._errors.push(`Failed to receive expected message: ${expected.messageType.typeName}`);
this._errors.push(`(${connection.name}) Failed to receive expected message: ${expected.messageType.typeName}`);
}

for (const expected of unsatisfiedSocketEvents) {
this._errors.push(`Failed to receive expected socket event: ${expected.eventType}`);
this._errors.push(`(${connection.name}) Failed to receive expected socket event: ${expected.eventType}`);
}

for (const message of unhandledMessages) {
this._errors.push(`Got message that was not expected/handled:: ${message.message.type}`);
this._errors.push(`(${connection.name}) Got message that was not expected/handled:: ${message.message.type}`);
}

for (const message of unhandledSocketEvents) {
this._errors.push(`Event not handled:: ${message.eventType}`);
this._errors.push(`(${connection.name}) Event not handled:: ${message.eventType}`);
}

for (const error of errors) {
Expand Down Expand Up @@ -158,10 +158,10 @@ export class SignallingConnection {
this.processTimer = null;

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));
this.protocol.transportEvents.addListener("message", message => this.onMessage(message));
this.protocol.transport.addListener("open", event => this.onConnectionOpen(event));
this.protocol.transport.addListener("error", event => this.onConnectionError(event));
this.protocol.transport.addListener("close", event => this.onConnectionClose(event));
this.protocol.transport.addListener("message", message => this.onMessage(message));

this.logCallback(this, `Connecting to Signalling Server at ${url}`);
this.protocol.connect(url);
Expand Down Expand Up @@ -385,6 +385,8 @@ export class SignallingConnection {
throw new Error('Unhandled internal event type');
}
}
eventsToRemove.sort();
expectingToRemove.sort();
for (var i = eventsToRemove.length - 1; i >= 0; --i) {
this.eventQueue.splice(eventsToRemove[i], 1);
}
Expand Down
2 changes: 1 addition & 1 deletion SS_Test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"esModuleInterop": true,
"target": "es5",
"moduleResolution": "node",
"sourceMap": false,
"sourceMap": true,
"allowJs": true,
"declaration": false
},
Expand Down

0 comments on commit c51db16

Please sign in to comment.