Merge all work on server with filmout features #77
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "1.7.14",
|
||||
"version": "1.7.15",
|
||||
"ext_port": 1111,
|
||||
"profiles": {
|
||||
"mcopy": {
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
/**
|
||||
* Delay in an async/await function
|
||||
*
|
||||
* @param {integer} ms Milliseconds to delay for
|
||||
*
|
||||
* @returns {Promise} Promise to resolve after timeout
|
||||
**/
|
||||
declare function delay(ms: number): Promise<unknown>;
|
|
@ -124,6 +124,10 @@ class FilmOut {
|
|||
this.log.error(err, 'FILMOUT', true, true);
|
||||
throw err;
|
||||
}
|
||||
if (this.server.displayImage(path)) {
|
||||
await delay_1.delay(20);
|
||||
return;
|
||||
}
|
||||
await this.display.show(path);
|
||||
await delay_1.delay(20);
|
||||
}
|
||||
|
@ -412,6 +416,9 @@ class FilmOut {
|
|||
throw err;
|
||||
}
|
||||
try {
|
||||
if (await this.server.displayImage(path)) {
|
||||
return;
|
||||
}
|
||||
await this.display.open();
|
||||
await this.display.show(path);
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
const ws_1 = require("ws");
|
||||
const express_1 = __importDefault(require("express"));
|
||||
const promises_1 = require("fs/promises");
|
||||
const mime_1 = __importDefault(require("mime"));
|
||||
const path_1 = require("path");
|
||||
const uuid_1 = require("uuid");
|
||||
const Log = require("log");
|
||||
class Server {
|
||||
|
@ -141,8 +141,7 @@ class Server {
|
|||
//wipe every time
|
||||
this.proxy = {};
|
||||
this.proxy[key] = {
|
||||
path: filePath,
|
||||
mime: mime_1.default.getType(filePath)
|
||||
path: filePath
|
||||
};
|
||||
this.log.info(`Added proxy image [${key}]`);
|
||||
}
|
||||
|
@ -157,6 +156,16 @@ class Server {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
async displayImage(src) {
|
||||
let key;
|
||||
if (this.isActive && this.wss.clients.size > 0) {
|
||||
key = path_1.basename(src);
|
||||
this.addProxy(key, src);
|
||||
await this.cmdAll('image', { image: `/image/${key}` });
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* WSS
|
||||
**/
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mcopy-app",
|
||||
"version": "1.7.14",
|
||||
"version": "1.7.15",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mcopy-app",
|
||||
"version": "1.7.14",
|
||||
"version": "1.7.15",
|
||||
"description": "GUI for the mcopy small gauge film optical printer platform",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "1.7.14",
|
||||
"version": "1.7.15",
|
||||
"ext_port": 1111,
|
||||
"profiles": {
|
||||
"mcopy": {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "mcopy",
|
||||
"version": "1.7.14",
|
||||
"version": "1.7.15",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "mcopy",
|
||||
"version": "1.7.14",
|
||||
"version": "1.7.15",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"arduino": "file:app/lib/arduino",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mcopy",
|
||||
"version": "1.7.14",
|
||||
"version": "1.7.15",
|
||||
"description": "Small gauge film optical printer platform",
|
||||
"main": "build.js",
|
||||
"directories": {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "1.7.14",
|
||||
"version": "1.7.15",
|
||||
"ext_port": 1111,
|
||||
"profiles": {
|
||||
"mcopy": {
|
||||
|
|
|
@ -135,6 +135,11 @@ class FilmOut {
|
|||
throw err;
|
||||
}
|
||||
|
||||
if (this.server.displayImage(path)) {
|
||||
await delay(20)
|
||||
return
|
||||
}
|
||||
|
||||
await this.display.show(path);
|
||||
await delay(20);
|
||||
}
|
||||
|
@ -432,6 +437,9 @@ class FilmOut {
|
|||
}
|
||||
|
||||
try {
|
||||
if (await this.server.displayImage(path)) {
|
||||
return
|
||||
}
|
||||
await this.display.open();
|
||||
await this.display.show(path);
|
||||
} catch (err) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import WebSocket, { WebSocketServer } from 'ws'
|
||||
import express, { Express, Request, Response, Application } from 'express'
|
||||
import { readFile } from 'fs/promises'
|
||||
import mime from 'mime'
|
||||
import { basename } from 'path'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import Log = require('log')
|
||||
import { delay } from 'delay';
|
||||
import { delay } from 'delay'
|
||||
|
||||
interface ServerData {
|
||||
[key: string]: string;
|
||||
|
@ -20,7 +20,6 @@ interface ServerTemplate {
|
|||
|
||||
interface ServerProxy {
|
||||
path : string;
|
||||
mime : string;
|
||||
}
|
||||
|
||||
interface ServerProxyList {
|
||||
|
@ -182,8 +181,7 @@ class Server {
|
|||
//wipe every time
|
||||
this.proxy = {}
|
||||
this.proxy[key] = {
|
||||
path : filePath,
|
||||
mime : mime.getType(filePath)
|
||||
path : filePath
|
||||
}
|
||||
this.log.info(`Added proxy image [${key}]`)
|
||||
}
|
||||
|
@ -200,6 +198,17 @@ class Server {
|
|||
return false
|
||||
}
|
||||
|
||||
public async displayImage (src : string) {
|
||||
let key
|
||||
if (this.isActive && this.wss.clients.size > 0) {
|
||||
key = basename(src)
|
||||
this.addProxy(key, src)
|
||||
await this.cmdAll('image', { image : `/image/${key}` })
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* WSS
|
||||
**/
|
||||
|
|
Loading…
Reference in New Issue