mirror of
https://github.com/ad1217/PrinterStatus
synced 2025-01-13 10:56:24 -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",
|
||||
"version": "0.0.0",
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^2.0.1",
|
||||
"sass": "^1.45.2",
|
||||
"typescript": "^4.5.4",
|
||||
"vite": "^2.7.10",
|
||||
"vue-tsc": "^0.30.2"
|
||||
"@vitejs/plugin-vue": "^3.0.3",
|
||||
"sass": "^1.54.5",
|
||||
"typescript": "^4.7.4",
|
||||
"vite": "^3.0.9",
|
||||
"vue-tsc": "^0.40.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@popperjs/core": "^2.11.2",
|
||||
"bootstrap": "^5.1.3",
|
||||
"hls.js": "^1.1.2",
|
||||
"@popperjs/core": "^2.11.6",
|
||||
"bootstrap": "^5.2.0",
|
||||
"hls.js": "^1.2.1",
|
||||
"pretty-ms": "^7.0.1",
|
||||
"vue": "^3.2.26"
|
||||
"vue": "^3.2.37"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "pnpm run -r --parallel dev",
|
||||
"start": "pnpm run -r --include-workspace-root --parallel dev",
|
||||
"server": "cd server && npm start",
|
||||
"dev": "vite",
|
||||
"build": "vue-tsc --noEmit && vite build",
|
||||
|
956
pnpm-lock.yaml
generated
956
pnpm-lock.yaml
generated
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/fluent-ffmpeg": "^2.1.20",
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"@types/node": "^17.0.8",
|
||||
"@types/node-fetch": "^2.5.12",
|
||||
"@types/ws": "^8.2.2",
|
||||
"ts-node": "^10.4.0",
|
||||
"typescript": "^4.5.4"
|
||||
"@types/node": "^18.7.11",
|
||||
"@types/node-fetch": "^2.6.2",
|
||||
"@types/ws": "^8.5.3",
|
||||
"ts-node-dev": "^2.0.0",
|
||||
"typescript": "^4.7.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^4.17.2",
|
||||
"express": "^4.18.1",
|
||||
"express-ws": "^5.0.2",
|
||||
"fluent-ffmpeg": "^2.1.2",
|
||||
"js-yaml": "^4.1.0",
|
||||
"mp4frag": "^0.5.4",
|
||||
"node-fetch": "^2.6.6",
|
||||
"ws": "^8.4.0"
|
||||
"mp4frag": "^0.6.0",
|
||||
"node-fetch": "^2.6.7",
|
||||
"ws": "^8.8.1"
|
||||
},
|
||||
"scripts": {
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
738
server/pnpm-lock.yaml
generated
738
server/pnpm-lock.yaml
generated
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';
|
||||
|
||||
const PING_TIME = 10000;
|
||||
const STATUS_TIMEOUT = 30000;
|
||||
|
||||
type Timeout = ReturnType<typeof setTimeout>;
|
||||
|
||||
@ -58,6 +59,7 @@ export default class OctoprintConnection {
|
||||
|
||||
let pingSender: ReturnType<typeof setInterval>;
|
||||
let pongTimeout: Timeout;
|
||||
let statusTimeout: Timeout;
|
||||
|
||||
const url = new URL('/sockjs/websocket', this.address);
|
||||
url.protocol = 'ws';
|
||||
@ -66,6 +68,14 @@ export default class OctoprintConnection {
|
||||
.on('open', () => {
|
||||
pingSender = setInterval(() => websocket.ping(), PING_TIME);
|
||||
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}"`);
|
||||
websocket.send(JSON.stringify({ auth: session_key }));
|
||||
@ -81,6 +91,7 @@ export default class OctoprintConnection {
|
||||
this.broadcast(ext_event);
|
||||
|
||||
if ('current' in event || 'history' in event) {
|
||||
clearTimeout(statusTimeout);
|
||||
this.lastStatus = ext_event;
|
||||
}
|
||||
})
|
||||
@ -90,6 +101,7 @@ export default class OctoprintConnection {
|
||||
.on('close', () => {
|
||||
clearInterval(pingSender);
|
||||
clearTimeout(pongTimeout);
|
||||
clearTimeout(statusTimeout);
|
||||
|
||||
console.log(
|
||||
`Lost connection to "${this.slug}", attempting reconnection in 5 seconds`
|
||||
|
@ -1,9 +1,11 @@
|
||||
{
|
||||
"include": ["src/**/*"],
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"strict": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "dist",
|
||||
"experimentalDecorators": true
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user