Skip to content

Commit

Permalink
fix: Detect corrupt sACN
Browse files Browse the repository at this point in the history
  • Loading branch information
schw4rzlicht committed Jun 14, 2020
1 parent ffdaf65 commit 675cbbc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/Twitch2Ma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {RuntimeInformation} from "./RuntimeInformation";
import {PermissionCollector, PermissionController, PermissionError} from "./PermissionController";

import SACNPermission, {
SACNCorrupt,
SACNLost,
SACNReceiving,
SACNStatus,
Expand Down Expand Up @@ -250,6 +251,10 @@ export default class Twitch2Ma extends EventEmitter {
case SACNStopped:
this.emit(this.onNotice, "sACN status: Stopped listening.");
break;
case SACNCorrupt:
this.emit(this.onNotice, "sACN status: Unexpected packet received. Are you using the \"final\" " +
"protocol version in your MA sACN settings?");
break;
default:
this.emit(this.onNotice, `sACN status: Received unknown status: ${typeof status}`);
// TODO sentry
Expand Down
10 changes: 10 additions & 0 deletions src/lib/permissions/SACNPermission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ export default class SACNPermission extends EventEmitter implements PermissionIn
}
});

this.sACNReceiver.on("PacketCorruption", () => {
this.emit(this.onStatus, new SACNCorrupt());
this.stop();
})

this.emit(this.onStatus, new SACNWaiting(universes));

this.watchdogTimeout = setInterval(() => this.watchdog(), this.config.sacn.timeout);
Expand Down Expand Up @@ -179,7 +184,12 @@ export class SACNLost extends SACNStatus {
}

export class SACNStopped extends SACNStatus {
constructor() {
super(null);
}
}

export class SACNCorrupt extends SACNStatus {
constructor() {
super(null);
}
Expand Down

0 comments on commit 675cbbc

Please sign in to comment.