Skip to content

Commit

Permalink
first test to narrow down problem (#2089)
Browse files Browse the repository at this point in the history
  • Loading branch information
UnchartedBull committed Jul 26, 2021
1 parent f763e1b commit 054f81e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/app/bottom-bar/bottom-bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export class BottomBarComponent implements OnDestroy {
}

public getStringStatus(printerState: PrinterState): string {
if (printerState === PrinterState.socketDead) {
return 'socket is dead';
}
return PrinterState[printerState];
}

Expand Down
1 change: 1 addition & 0 deletions src/app/model/printer.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export enum PrinterState {
closed,
connecting,
reconnecting,
socketDead,
}
8 changes: 7 additions & 1 deletion src/app/services/socket/socket.octoprint.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { SocketService } from './socket.service';
@Injectable()
export class OctoPrintSocketService implements SocketService {
private fastInterval = 0;
private socketDeadTimeout: ReturnType<typeof setTimeout>;
private socket: WebSocketSubject<unknown>;

private printerStatusSubject: Subject<PrinterStatus>;
Expand Down Expand Up @@ -119,6 +120,11 @@ export class OctoPrintSocketService implements SocketService {
private setupSocket(resolve: () => void) {
this.socket.subscribe(
message => {
clearTimeout(this.socketDeadTimeout);
this.socketDeadTimeout = setTimeout(() => {
this.printerStatus.status = PrinterState.socketDead;
this.printerStatusSubject.next(this.printerStatus);
}, 30000);
if (Object.hasOwnProperty.bind(message)('current')) {
this.extractPrinterStatus(message as OctoprintSocketCurrent);
this.extractJobStatus(message as OctoprintSocketCurrent);
Expand All @@ -133,7 +139,7 @@ export class OctoPrintSocketService implements SocketService {
this.extractFanSpeed(pluginMessage.plugin.data as DisplayLayerProgressData);
this.extractLayerHeight(pluginMessage.plugin.data as DisplayLayerProgressData);
}
} else if (Object.hasOwnProperty.bind(message)('reauth')) {
} else if (Object.hasOwnProperty.bind(message)('reauthRequired')) {
this.systemService.getSessionKey().subscribe(socketAuth => this.authenticateSocket(socketAuth));
} else if (Object.hasOwnProperty.bind(message)('connected')) {
resolve();
Expand Down

0 comments on commit 054f81e

Please sign in to comment.