Various changed to improve performance and loading of modules

This commit is contained in:
Core 2022-02-04 03:36:00 +00:00
parent 1a1842ad41
commit 0efd4eb643
No known key found for this signature in database
GPG key ID: FE9BF1B547F8F3C6
4 changed files with 118 additions and 108 deletions

View file

@ -1,19 +1,19 @@
import * as path from "path"; import {join} from "path";
import {app, BrowserWindow as bw, ipcMain, shell} from "electron"; import {app, BrowserWindow as bw, ipcMain, shell} from "electron";
import * as windowStateKeeper from "electron-window-state"; import * as windowStateKeeper from "electron-window-state";
import * as express from "express"; import * as express from "express";
import * as getPort from "get-port"; import * as getPort from "get-port";
import * as yt from "youtube-search-without-api-key"; import {search} from "youtube-search-without-api-key";
import * as fs from "fs"; import {existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync} from "fs";
import {Stream} from "stream"; import {Stream} from "stream";
import * as qrcode from "qrcode-terminal"; import {generate as generateQR} from "qrcode-terminal";
import * as os from "os"; import {hostname, networkInterfaces} from "os";
import * as mm from 'music-metadata'; import * as mm from 'music-metadata';
import fetch from 'electron-fetch' import fetch from 'electron-fetch'
import {wsapi} from "./wsapi"; import {wsapi} from "./wsapi";
import {jsonc} from "jsonc"; import {jsonc} from "jsonc";
import {AppImageUpdater, NsisUpdater} from "electron-updater"; import {AppImageUpdater, NsisUpdater} from "electron-updater";
import {utils} from './utils' import {utils} from './utils';
export class BrowserWindow { export class BrowserWindow {
public static win: any | undefined = null; public static win: any | undefined = null;
@ -29,7 +29,7 @@ export class BrowserWindow {
}, },
}; };
private options: any = { private options: any = {
icon: path.join( icon: join(
utils.getPath('resourcePath'), utils.getPath('resourcePath'),
`icons/icon.` + (process.platform === "win32" ? "ico" : "png") `icons/icon.` + (process.platform === "win32" ? "ico" : "png")
), ),
@ -57,7 +57,7 @@ export class BrowserWindow {
plugins: true, plugins: true,
nodeIntegrationInWorker: false, nodeIntegrationInWorker: false,
webSecurity: false, webSecurity: false,
preload: path.join(utils.getPath('srcPath'), "./preload/cider-preload.js"), preload: join(utils.getPath('srcPath'), "./preload/cider-preload.js"),
}, },
}; };
@ -66,7 +66,7 @@ export class BrowserWindow {
*/ */
async createWindow(): Promise<Electron.BrowserWindow> { async createWindow(): Promise<Electron.BrowserWindow> {
this.clientPort = await getPort({port: 9000}); this.clientPort = await getPort({port: 9000});
this.verifyFiles(); BrowserWindow.verifyFiles();
// Load the previous state with fallback to defaults // Load the previous state with fallback to defaults
const windowState = windowStateKeeper({ const windowState = windowStateKeeper({
@ -96,7 +96,7 @@ export class BrowserWindow {
/** /**
* Verifies the files for the renderer to use (Cache, library info, etc.) * Verifies the files for the renderer to use (Cache, library info, etc.)
*/ */
private verifyFiles(): void { private static verifyFiles(): void {
const expectedDirectories = ["CiderCache"]; const expectedDirectories = ["CiderCache"];
const expectedFiles = [ const expectedFiles = [
"library-songs.json", "library-songs.json",
@ -107,19 +107,19 @@ export class BrowserWindow {
]; ];
for (let i = 0; i < expectedDirectories.length; i++) { for (let i = 0; i < expectedDirectories.length; i++) {
if ( if (
!fs.existsSync( !existsSync(
path.join(app.getPath("userData"), expectedDirectories[i]) join(app.getPath("userData"), expectedDirectories[i])
) )
) { ) {
fs.mkdirSync( mkdirSync(
path.join(app.getPath("userData"), expectedDirectories[i]) join(app.getPath("userData"), expectedDirectories[i])
); );
} }
} }
for (let i = 0; i < expectedFiles.length; i++) { for (let i = 0; i < expectedFiles.length; i++) {
const file = path.join(utils.getPath('ciderCache'), expectedFiles[i]); const file = join(utils.getPath('ciderCache'), expectedFiles[i]);
if (!fs.existsSync(file)) { if (!existsSync(file)) {
fs.writeFileSync(file, JSON.stringify([])); writeFileSync(file, JSON.stringify([]));
} }
} }
} }
@ -130,8 +130,8 @@ export class BrowserWindow {
private startWebServer(): void { private startWebServer(): void {
const app = express(); const app = express();
app.use(express.static(path.join(utils.getPath('srcPath'), "./renderer/"))); app.use(express.static(join(utils.getPath('srcPath'), "./renderer/")));
app.set("views", path.join(utils.getPath('srcPath'), "./renderer/views")); app.set("views", join(utils.getPath('srcPath'), "./renderer/views"));
app.set("view engine", "ejs"); app.set("view engine", "ejs");
let firstRequest = true; let firstRequest = true;
app.use((req, res, next) => { app.use((req, res, next) => {
@ -152,11 +152,11 @@ export class BrowserWindow {
app.get("/themes/:theme", (req, res) => { app.get("/themes/:theme", (req, res) => {
const theme = req.params.theme.toLowerCase(); const theme = req.params.theme.toLowerCase();
const themePath = path.join(utils.getPath('srcPath'), "./renderer/themes/", theme); const themePath = join(utils.getPath('srcPath'), "./renderer/themes/", theme);
const userThemePath = path.join(utils.getPath('themes'), theme); const userThemePath = join(utils.getPath('themes'), theme);
if (fs.existsSync(userThemePath)) { if (existsSync(userThemePath)) {
res.sendFile(userThemePath); res.sendFile(userThemePath);
} else if (fs.existsSync(themePath)) { } else if (existsSync(themePath)) {
res.sendFile(themePath); res.sendFile(themePath);
} else { } else {
res.send(`// Theme not found - ${userThemePath}`); res.send(`// Theme not found - ${userThemePath}`);
@ -197,8 +197,8 @@ export class BrowserWindow {
* https://github.com/ciderapp/Apple-Music-Electron/blob/818ed18940ff600d76eb59d22016723a75885cd5/resources/functions/handler.js#L1173 * https://github.com/ciderapp/Apple-Music-Electron/blob/818ed18940ff600d76eb59d22016723a75885cd5/resources/functions/handler.js#L1173
*/ */
const remote = express(); const remote = express();
remote.use(express.static(path.join(utils.getPath('srcPath'), "./web-remote/"))) remote.use(express.static(join(utils.getPath('srcPath'), "./web-remote/")))
remote.set("views", path.join(utils.getPath('srcPath'), "./web-remote/views")); remote.set("views", join(utils.getPath('srcPath'), "./web-remote/views"));
remote.set("view engine", "ejs"); remote.set("view engine", "ejs");
getPort({port: 6942}).then((port) => { getPort({port: 6942}).then((port) => {
this.remotePort = port; this.remotePort = port;
@ -208,7 +208,7 @@ export class BrowserWindow {
console.log(`Cider remote port: ${this.remotePort}`); console.log(`Cider remote port: ${this.remotePort}`);
if (firstRequest) { if (firstRequest) {
console.log("---- Ignore Me ;) ---"); console.log("---- Ignore Me ;) ---");
qrcode.generate(`http://${os.hostname}:${this.remotePort}`); generateQR(`http://${hostname}:${this.remotePort}`);
console.log("---- Ignore Me ;) ---"); console.log("---- Ignore Me ;) ---");
/* /*
* *
@ -290,9 +290,9 @@ export class BrowserWindow {
event.returnValue = process.platform; event.returnValue = process.platform;
}); });
ipcMain.on("get-themes", (event, key) => { ipcMain.on("get-themes", (event, _key) => {
if (fs.existsSync(utils.getPath("themes"))) { if (existsSync(utils.getPath("themes"))) {
event.returnValue = fs.readdirSync(utils.getPath("themes")); event.returnValue = readdirSync(utils.getPath("themes"));
} else { } else {
event.returnValue = []; event.returnValue = [];
} }
@ -303,11 +303,11 @@ export class BrowserWindow {
}); });
ipcMain.on("get-i18n-listing", event => { ipcMain.on("get-i18n-listing", event => {
let i18nFiles = fs.readdirSync(path.join(__dirname, "../../src/i18n")).filter(file => file.endsWith(".jsonc")); let i18nFiles = readdirSync(join(__dirname, "../../src/i18n")).filter(file => file.endsWith(".jsonc"));
// read all the files and parse them // read all the files and parse them
let i18nListing = [] let i18nListing = []
for (let i = 0; i < i18nFiles.length; i++) { for (let i = 0; i < i18nFiles.length; i++) {
const i18n: { [index: string]: Object } = jsonc.parse(fs.readFileSync(path.join(__dirname, `../../src/i18n/${i18nFiles[i]}`), "utf8")); const i18n: { [index: string]: Object } = jsonc.parse(readFileSync(join(__dirname, `../../src/i18n/${i18nFiles[i]}`), "utf8"));
i18nListing.push({ i18nListing.push({
"code": i18nFiles[i].replace(".jsonc", ""), "code": i18nFiles[i].replace(".jsonc", ""),
"nameNative": i18n["i18n.languageName"] ?? i18nFiles[i].replace(".jsonc", ""), "nameNative": i18n["i18n.languageName"] ?? i18nFiles[i].replace(".jsonc", ""),
@ -328,75 +328,75 @@ export class BrowserWindow {
}); });
ipcMain.on("put-library-songs", (_event, arg) => { ipcMain.on("put-library-songs", (_event, arg) => {
fs.writeFileSync( writeFileSync(
path.join(utils.getPath('ciderCache'), "library-songs.json"), join(utils.getPath('ciderCache'), "library-songs.json"),
JSON.stringify(arg) JSON.stringify(arg)
); );
}); });
ipcMain.on("put-library-artists", (_event, arg) => { ipcMain.on("put-library-artists", (_event, arg) => {
fs.writeFileSync( writeFileSync(
path.join(utils.getPath('ciderCache'), "library-artists.json"), join(utils.getPath('ciderCache'), "library-artists.json"),
JSON.stringify(arg) JSON.stringify(arg)
); );
}); });
ipcMain.on("put-library-albums", (_event, arg) => { ipcMain.on("put-library-albums", (_event, arg) => {
fs.writeFileSync( writeFileSync(
path.join(utils.getPath('ciderCache'), "library-albums.json"), join(utils.getPath('ciderCache'), "library-albums.json"),
JSON.stringify(arg) JSON.stringify(arg)
); );
}); });
ipcMain.on("put-library-playlists", (_event, arg) => { ipcMain.on("put-library-playlists", (_event, arg) => {
fs.writeFileSync( writeFileSync(
path.join(utils.getPath('ciderCache'), "library-playlists.json"), join(utils.getPath('ciderCache'), "library-playlists.json"),
JSON.stringify(arg) JSON.stringify(arg)
); );
}); });
ipcMain.on("put-library-recentlyAdded", (_event, arg) => { ipcMain.on("put-library-recentlyAdded", (_event, arg) => {
fs.writeFileSync( writeFileSync(
path.join(utils.getPath('ciderCache'), "library-recentlyAdded.json"), join(utils.getPath('ciderCache'), "library-recentlyAdded.json"),
JSON.stringify(arg) JSON.stringify(arg)
); );
}); });
ipcMain.on("get-library-songs", (event) => { ipcMain.on("get-library-songs", (event) => {
let librarySongs = fs.readFileSync( let librarySongs = readFileSync(
path.join(utils.getPath('ciderCache'), "library-songs.json"), join(utils.getPath('ciderCache'), "library-songs.json"),
"utf8" "utf8"
); );
event.returnValue = JSON.parse(librarySongs); event.returnValue = JSON.parse(librarySongs);
}); });
ipcMain.on("get-library-artists", (event) => { ipcMain.on("get-library-artists", (event) => {
let libraryArtists = fs.readFileSync( let libraryArtists = readFileSync(
path.join(utils.getPath('ciderCache'), "library-artists.json"), join(utils.getPath('ciderCache'), "library-artists.json"),
"utf8" "utf8"
); );
event.returnValue = JSON.parse(libraryArtists); event.returnValue = JSON.parse(libraryArtists);
}); });
ipcMain.on("get-library-albums", (event) => { ipcMain.on("get-library-albums", (event) => {
let libraryAlbums = fs.readFileSync( let libraryAlbums = readFileSync(
path.join(utils.getPath('ciderCache'), "library-albums.json"), join(utils.getPath('ciderCache'), "library-albums.json"),
"utf8" "utf8"
); );
event.returnValue = JSON.parse(libraryAlbums); event.returnValue = JSON.parse(libraryAlbums);
}); });
ipcMain.on("get-library-playlists", (event) => { ipcMain.on("get-library-playlists", (event) => {
let libraryPlaylists = fs.readFileSync( let libraryPlaylists = readFileSync(
path.join(utils.getPath('ciderCache'), "library-playlists.json"), join(utils.getPath('ciderCache'), "library-playlists.json"),
"utf8" "utf8"
); );
event.returnValue = JSON.parse(libraryPlaylists); event.returnValue = JSON.parse(libraryPlaylists);
}); });
ipcMain.on("get-library-recentlyAdded", (event) => { ipcMain.on("get-library-recentlyAdded", (event) => {
let libraryRecentlyAdded = fs.readFileSync( let libraryRecentlyAdded = readFileSync(
path.join(utils.getPath('ciderCache'), "library-recentlyAdded.json"), join(utils.getPath('ciderCache'), "library-recentlyAdded.json"),
"utf8" "utf8"
); );
event.returnValue = JSON.parse(libraryRecentlyAdded); event.returnValue = JSON.parse(libraryRecentlyAdded);
@ -404,7 +404,7 @@ export class BrowserWindow {
ipcMain.handle("getYTLyrics", async (_event, track, artist) => { ipcMain.handle("getYTLyrics", async (_event, track, artist) => {
const u = track + " " + artist + " official video"; const u = track + " " + artist + " official video";
return await yt.search(u); return await search(u);
}); });
ipcMain.on("close", (_event, platformCheck) => { ipcMain.on("close", (_event, platformCheck) => {
@ -470,7 +470,7 @@ export class BrowserWindow {
}) })
//QR Code //QR Code
ipcMain.handle('showQR', async (event, _) => { ipcMain.handle('showQR', async (_event, _) => {
let url = `http://${BrowserWindow.getIP()}:${this.remotePort}`; let url = `http://${BrowserWindow.getIP()}:${this.remotePort}`;
shell.openExternal(`https://cider.sh/pair-remote?url=${Buffer.from(encodeURI(url)).toString('base64')}`).catch(console.error); shell.openExternal(`https://cider.sh/pair-remote?url=${Buffer.from(encodeURI(url)).toString('base64')}`).catch(console.error);
}) })
@ -490,7 +490,7 @@ export class BrowserWindow {
}); });
}); });
ipcMain.on('check-for-update', async (_event, url) => { ipcMain.on('check-for-update', async (_event) => {
const options: any = { const options: any = {
provider: 'generic', provider: 'generic',
url: 'https://43-429851205-gh.circle-artifacts.com/0/%7E/Cider/dist/artifacts' //Base URL url: 'https://43-429851205-gh.circle-artifacts.com/0/%7E/Cider/dist/artifacts' //Base URL
@ -570,10 +570,14 @@ export class BrowserWindow {
}); });
} }
/**
* Gets ip
* @private
*/
private static getIP(): string { private static getIP(): string {
let ip: string = ''; let ip: string = '';
let alias = 0; let alias = 0;
const ifaces: any = os.networkInterfaces(); const ifaces: any = networkInterfaces();
for (let dev in ifaces) { for (let dev in ifaces) {
ifaces[dev].forEach((details: any) => { ifaces[dev].forEach((details: any) => {
if (details.family === 'IPv4') { if (details.family === 'IPv4') {

View file

@ -142,11 +142,11 @@ export class Store {
* IPC Handler * IPC Handler
*/ */
private ipcHandler(): void { private ipcHandler(): void {
electron.ipcMain.handle('getStoreValue', (event, key, defaultValue) => { electron.ipcMain.handle('getStoreValue', (_event, key, defaultValue) => {
return (defaultValue ? Store.cfg.get(key, true) : Store.cfg.get(key)); return (defaultValue ? Store.cfg.get(key, true) : Store.cfg.get(key));
}); });
electron.ipcMain.handle('setStoreValue', (event, key, value) => { electron.ipcMain.handle('setStoreValue', (_event, key, value) => {
Store.cfg.set(key, value); Store.cfg.set(key, value);
}); });
@ -154,7 +154,7 @@ export class Store {
event.returnValue = Store.cfg.store event.returnValue = Store.cfg.store
}) })
electron.ipcMain.on('setStore', (event, store) => { electron.ipcMain.on('setStore', (_event, store) => {
Store.cfg.store = store Store.cfg.store = store
}) })
} }

View file

@ -13,6 +13,7 @@ export class utils {
private static paths: any = { private static paths: any = {
srcPath: path.join(__dirname, "../../src"), srcPath: path.join(__dirname, "../../src"),
resourcePath: path.join(__dirname, "../../resources"), resourcePath: path.join(__dirname, "../../resources"),
i18nPath: path.join(__dirname, "../../src/i18n"),
ciderCache: path.resolve(app.getPath("userData"), "CiderCache"), ciderCache: path.resolve(app.getPath("userData"), "CiderCache"),
themes: path.resolve(app.getPath("userData"), "Themes"), themes: path.resolve(app.getPath("userData"), "Themes"),
plugins: path.resolve(app.getPath("userData"), "Plugins"), plugins: path.resolve(app.getPath("userData"), "Plugins"),
@ -34,10 +35,10 @@ export class utils {
* @returns {string | Object} The locale value. * @returns {string | Object} The locale value.
*/ */
static getLocale(language: string, key?: string): string | object { static getLocale(language: string, key?: string): string | object {
let i18n: { [index: string]: Object } = jsonc.parse(fs.readFileSync(path.join(__dirname, "../../src/i18n/en_US.jsonc"), "utf8")); let i18n: { [index: string]: Object } = jsonc.parse(fs.readFileSync(path.join(this.paths.i18nPath, "en_US.jsonc"), "utf8"));
if (language !== "en_US" && fs.existsSync(path.join(__dirname, `../../src/i18n/${language}.jsonc`))) { if (language !== "en_US" && fs.existsSync(path.join(this.paths.i18nPath, `${language}.jsonc`))) {
i18n = Object.assign(i18n, jsonc.parse(fs.readFileSync(path.join(__dirname, `../../src/i18n/${language}.jsonc`), "utf8"))); i18n = Object.assign(i18n, jsonc.parse(fs.readFileSync(path.join(this.paths.i18nPath, `${language}.jsonc`), "utf8")));
} }
if (key) { if (key) {

View file

@ -1,11 +1,6 @@
import * as ws from "ws"; import * as ws from "ws";
import * as http from "http";
import * as https from "https";
import * as url from "url";
import * as fs from "fs";
import * as path from "path";
import * as electron from "electron"; import * as electron from "electron";
const WebSocket = ws;
const WebSocketServer = ws.Server; const WebSocketServer = ws.Server;
interface standardResponse { interface standardResponse {
@ -22,6 +17,7 @@ export class wsapi {
wss: any = null wss: any = null
clients: any = [] clients: any = []
private _win: any; private _win: any;
constructor(win: any) { constructor(win: any) {
this._win = win; this._win = win;
} }
@ -35,33 +31,34 @@ export class wsapi {
return v.toString(16); return v.toString(16);
}); });
} }
public async InitWebSockets() { public async InitWebSockets() {
electron.ipcMain.on('wsapi-updatePlaybackState', (event :any, arg :any) => { electron.ipcMain.on('wsapi-updatePlaybackState', (_event: any, arg: any) => {
this.updatePlaybackState(arg); this.updatePlaybackState(arg);
}) })
electron.ipcMain.on('wsapi-returnQueue', (event :any, arg :any) => { electron.ipcMain.on('wsapi-returnQueue', (_event: any, arg: any) => {
this.returnQueue(JSON.parse(arg)); this.returnQueue(JSON.parse(arg));
}); });
electron.ipcMain.on('wsapi-returnSearch', (event :any, arg :any) => { electron.ipcMain.on('wsapi-returnSearch', (_event: any, arg: any) => {
console.log("SEARCH") console.log("SEARCH")
this.returnSearch(JSON.parse(arg)); this.returnSearch(JSON.parse(arg));
}); });
electron.ipcMain.on('wsapi-returnSearchLibrary', (event :any, arg :any) => { electron.ipcMain.on('wsapi-returnSearchLibrary', (_event: any, arg: any) => {
this.returnSearchLibrary(JSON.parse(arg)); this.returnSearchLibrary(JSON.parse(arg));
}); });
electron.ipcMain.on('wsapi-returnDynamic', (event :any, arg :any, type :any) => { electron.ipcMain.on('wsapi-returnDynamic', (_event: any, arg: any, type: any) => {
this.returnDynamic(JSON.parse(arg), type); this.returnDynamic(JSON.parse(arg), type);
}); });
electron.ipcMain.on('wsapi-returnMusicKitApi', (event :any, arg :any, method :any) => { electron.ipcMain.on('wsapi-returnMusicKitApi', (_event: any, arg: any, method: any) => {
this.returnMusicKitApi(JSON.parse(arg), method); this.returnMusicKitApi(JSON.parse(arg), method);
}); });
electron.ipcMain.on('wsapi-returnLyrics', (event :any, arg :any) => { electron.ipcMain.on('wsapi-returnLyrics', (_event: any, arg: any) => {
this.returnLyrics(JSON.parse(arg)); this.returnLyrics(JSON.parse(arg));
}); });
this.wss = new WebSocketServer({ this.wss = new WebSocketServer({
@ -95,7 +92,7 @@ export class wsapi {
ws.id = this.createId(); ws.id = this.createId();
console.log(`Client ${ws.id} connected`) console.log(`Client ${ws.id} connected`)
this.clients.push(ws); this.clients.push(ws);
ws.on('message', function incoming(message : any) { ws.on('message', function incoming(_message: any) {
}); });
// ws on message // ws on message
@ -245,45 +242,53 @@ export class wsapi {
ws.send(JSON.stringify(defaultResponse)); ws.send(JSON.stringify(defaultResponse));
}); });
} }
sendToClient(id : any) {
sendToClient(_id: any) {
// replace the clients.forEach with a filter to find the client that requested // replace the clients.forEach with a filter to find the client that requested
} }
updatePlaybackState(attr: any) { updatePlaybackState(attr: any) {
const response: standardResponse = {status: 0, data: attr, message: "OK", type: "playbackStateUpdate"}; const response: standardResponse = {status: 0, data: attr, message: "OK", type: "playbackStateUpdate"};
this.clients.forEach(function each(client: any) { this.clients.forEach(function each(client: any) {
client.send(JSON.stringify(response)); client.send(JSON.stringify(response));
}); });
} }
returnMusicKitApi(results: any, method: any) { returnMusicKitApi(results: any, method: any) {
const response: standardResponse = {status: 0, data: results, message: "OK", type: `musickitapi.${method}`}; const response: standardResponse = {status: 0, data: results, message: "OK", type: `musickitapi.${method}`};
this.clients.forEach(function each(client: any) { this.clients.forEach(function each(client: any) {
client.send(JSON.stringify(response)); client.send(JSON.stringify(response));
}); });
} }
returnDynamic(results: any, type: any) { returnDynamic(results: any, type: any) {
const response: standardResponse = {status: 0, data: results, message: "OK", type: type}; const response: standardResponse = {status: 0, data: results, message: "OK", type: type};
this.clients.forEach(function each(client: any) { this.clients.forEach(function each(client: any) {
client.send(JSON.stringify(response)); client.send(JSON.stringify(response));
}); });
} }
returnLyrics(results: any) { returnLyrics(results: any) {
const response: standardResponse = {status: 0, data: results, message: "OK", type: "lyrics"}; const response: standardResponse = {status: 0, data: results, message: "OK", type: "lyrics"};
this.clients.forEach(function each(client: any) { this.clients.forEach(function each(client: any) {
client.send(JSON.stringify(response)); client.send(JSON.stringify(response));
}); });
} }
returnSearch(results: any) { returnSearch(results: any) {
const response: standardResponse = {status: 0, data: results, message: "OK", type: "searchResults"}; const response: standardResponse = {status: 0, data: results, message: "OK", type: "searchResults"};
this.clients.forEach(function each(client: any) { this.clients.forEach(function each(client: any) {
client.send(JSON.stringify(response)); client.send(JSON.stringify(response));
}); });
} }
returnSearchLibrary(results: any) { returnSearchLibrary(results: any) {
const response: standardResponse = {status: 0, data: results, message: "OK", type: "searchResultsLibrary"}; const response: standardResponse = {status: 0, data: results, message: "OK", type: "searchResultsLibrary"};
this.clients.forEach(function each(client: any) { this.clients.forEach(function each(client: any) {
client.send(JSON.stringify(response)); client.send(JSON.stringify(response));
}); });
} }
returnQueue(queue: any) { returnQueue(queue: any) {
const response: standardResponse = {status: 0, data: queue, message: "OK", type: "queue"}; const response: standardResponse = {status: 0, data: queue, message: "OK", type: "queue"};
this.clients.forEach(function each(client: any) { this.clients.forEach(function each(client: any) {