mirror of
https://github.com/ad1217/PrinterStatus
synced 2024-11-10 18:45:08 -05:00
Compare commits
6 Commits
d6a3fb766f
...
f39366cd82
Author | SHA1 | Date | |
---|---|---|---|
f39366cd82 | |||
eddad957b7 | |||
5955ff2276 | |||
8d41813759 | |||
70a16a45ba | |||
11996e5174 |
20
package.json
20
package.json
@ -2,21 +2,21 @@
|
|||||||
"name": "printer_status",
|
"name": "printer_status",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^2.0.1",
|
"@vitejs/plugin-vue": "^3.0.3",
|
||||||
"sass": "^1.45.2",
|
"sass": "^1.54.5",
|
||||||
"typescript": "^4.5.4",
|
"typescript": "^4.7.4",
|
||||||
"vite": "^2.7.10",
|
"vite": "^3.0.9",
|
||||||
"vue-tsc": "^0.30.2"
|
"vue-tsc": "^0.40.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@popperjs/core": "^2.11.2",
|
"@popperjs/core": "^2.11.6",
|
||||||
"bootstrap": "^5.1.3",
|
"bootstrap": "^5.2.0",
|
||||||
"hls.js": "^1.1.2",
|
"hls.js": "^1.2.1",
|
||||||
"pretty-ms": "^7.0.1",
|
"pretty-ms": "^7.0.1",
|
||||||
"vue": "^3.2.26"
|
"vue": "^3.2.37"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "pnpm run -r --parallel dev",
|
"start": "pnpm run -r --include-workspace-root --parallel dev",
|
||||||
"server": "cd server && npm start",
|
"server": "cd server && npm start",
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vue-tsc --noEmit && vite build",
|
"build": "vue-tsc --noEmit && vite build",
|
||||||
|
956
pnpm-lock.yaml
956
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
1
server/.gitignore
vendored
Normal file
1
server/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
dist/
|
@ -4,23 +4,25 @@
|
|||||||
"@types/express-ws": "^3.0.1",
|
"@types/express-ws": "^3.0.1",
|
||||||
"@types/fluent-ffmpeg": "^2.1.20",
|
"@types/fluent-ffmpeg": "^2.1.20",
|
||||||
"@types/js-yaml": "^4.0.5",
|
"@types/js-yaml": "^4.0.5",
|
||||||
"@types/node": "^17.0.8",
|
"@types/node": "^18.7.11",
|
||||||
"@types/node-fetch": "^2.5.12",
|
"@types/node-fetch": "^2.6.2",
|
||||||
"@types/ws": "^8.2.2",
|
"@types/ws": "^8.5.3",
|
||||||
"ts-node": "^10.4.0",
|
"ts-node-dev": "^2.0.0",
|
||||||
"typescript": "^4.5.4"
|
"typescript": "^4.7.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^4.17.2",
|
"express": "^4.18.1",
|
||||||
"express-ws": "^5.0.2",
|
"express-ws": "^5.0.2",
|
||||||
"fluent-ffmpeg": "^2.1.2",
|
"fluent-ffmpeg": "^2.1.2",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"mp4frag": "^0.5.4",
|
"mp4frag": "^0.6.0",
|
||||||
"node-fetch": "^2.6.6",
|
"node-fetch": "^2.6.7",
|
||||||
"ws": "^8.4.0"
|
"ws": "^8.8.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "npm run dev",
|
"start": "npm run dev",
|
||||||
"dev": "ts-node --files ./src/server.ts"
|
"dev": "ts-node-dev --files ./src/server.ts",
|
||||||
|
"build": "tsc",
|
||||||
|
"serve": "node dist/server.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -7,6 +7,7 @@ import { Message, StatusMessage, SettingsMessage } from '../../types/messages';
|
|||||||
import * as octoprint from '../../types/octoprint';
|
import * as octoprint from '../../types/octoprint';
|
||||||
|
|
||||||
const PING_TIME = 10000;
|
const PING_TIME = 10000;
|
||||||
|
const STATUS_TIMEOUT = 30000;
|
||||||
|
|
||||||
type Timeout = ReturnType<typeof setTimeout>;
|
type Timeout = ReturnType<typeof setTimeout>;
|
||||||
|
|
||||||
@ -58,6 +59,7 @@ export default class OctoprintConnection {
|
|||||||
|
|
||||||
let pingSender: ReturnType<typeof setInterval>;
|
let pingSender: ReturnType<typeof setInterval>;
|
||||||
let pongTimeout: Timeout;
|
let pongTimeout: Timeout;
|
||||||
|
let statusTimeout: Timeout;
|
||||||
|
|
||||||
const url = new URL('/sockjs/websocket', this.address);
|
const url = new URL('/sockjs/websocket', this.address);
|
||||||
url.protocol = 'ws';
|
url.protocol = 'ws';
|
||||||
@ -66,6 +68,14 @@ export default class OctoprintConnection {
|
|||||||
.on('open', () => {
|
.on('open', () => {
|
||||||
pingSender = setInterval(() => websocket.ping(), PING_TIME);
|
pingSender = setInterval(() => websocket.ping(), PING_TIME);
|
||||||
pongTimeout = this.heartbeat(websocket, pongTimeout);
|
pongTimeout = this.heartbeat(websocket, pongTimeout);
|
||||||
|
statusTimeout = setTimeout(() => {
|
||||||
|
console.log(
|
||||||
|
`No status recieved in ${STATUS_TIMEOUT / 1000}s for "${
|
||||||
|
this.slug
|
||||||
|
}", disconnecting`
|
||||||
|
);
|
||||||
|
websocket.terminate();
|
||||||
|
}, STATUS_TIMEOUT);
|
||||||
|
|
||||||
console.log(`Connected to "${this.slug}"`);
|
console.log(`Connected to "${this.slug}"`);
|
||||||
websocket.send(JSON.stringify({ auth: session_key }));
|
websocket.send(JSON.stringify({ auth: session_key }));
|
||||||
@ -81,6 +91,7 @@ export default class OctoprintConnection {
|
|||||||
this.broadcast(ext_event);
|
this.broadcast(ext_event);
|
||||||
|
|
||||||
if ('current' in event || 'history' in event) {
|
if ('current' in event || 'history' in event) {
|
||||||
|
clearTimeout(statusTimeout);
|
||||||
this.lastStatus = ext_event;
|
this.lastStatus = ext_event;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -90,6 +101,7 @@ export default class OctoprintConnection {
|
|||||||
.on('close', () => {
|
.on('close', () => {
|
||||||
clearInterval(pingSender);
|
clearInterval(pingSender);
|
||||||
clearTimeout(pongTimeout);
|
clearTimeout(pongTimeout);
|
||||||
|
clearTimeout(statusTimeout);
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`Lost connection to "${this.slug}", attempting reconnection in 5 seconds`
|
`Lost connection to "${this.slug}", attempting reconnection in 5 seconds`
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
{
|
{
|
||||||
|
"include": ["src/**/*"],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
|
"outDir": "dist",
|
||||||
"experimentalDecorators": true
|
"experimentalDecorators": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user