Remove unneeded dependency

This commit is contained in:
Timothy Warren 2018-04-17 14:12:55 -04:00
parent 2bad69ace0
commit eb536063db
5 changed files with 21 additions and 19 deletions

View File

@ -12,7 +12,6 @@
"inferno-bootstrap": "^5.0.0", "inferno-bootstrap": "^5.0.0",
"inferno-dev-utils": "^5.3.0", "inferno-dev-utils": "^5.3.0",
"inferno-router": "^5.0.1", "inferno-router": "^5.0.1",
"isomorphic-ws": "^4.0.0",
"lodash": "^4.17.5", "lodash": "^4.17.5",
"ws": "^5.1.1" "ws": "^5.1.1"
}, },

View File

@ -1,7 +1,6 @@
import * as _ from 'lodash'; import * as _ from 'lodash';
import { Component } from 'inferno'; import { Component } from 'inferno';
import { BrowserRouter, Link, NavLink } from 'inferno-router'; import { BrowserRouter, Link, NavLink } from 'inferno-router';
import WS from 'isomorphic-ws';
import { Loader } from './components'; import { Loader } from './components';
import { import {
Container, Container,
@ -27,7 +26,7 @@ export class App extends Component {
} }
componentDidMount () { componentDidMount () {
window.clientWS = new WS('ws://localhost:65432/'); window.clientWS = new WebSocket('ws://localhost:65432/');
window.clientWS.addEventListener('open', this.onWebSocketOpen); window.clientWS.addEventListener('open', this.onWebSocketOpen);
window.clientWS.addEventListener('message', console); window.clientWS.addEventListener('message', console);

View File

@ -6,7 +6,9 @@ log.transports.console.level = 'info';
const path = require('path'); const path = require('path');
const url = require('url'); const url = require('url');
const WS = require('isomorphic-ws');
// eslint-disable-next-line
const WebSocket = require('ws');
// eslint-disable-next-line // eslint-disable-next-line
global.eval = () => {}; global.eval = () => {};
@ -71,9 +73,17 @@ app.on('activate', () => {
} }
}); });
const wss = new WS.Server({ const wss = new WebSocket.Server({
perMessageDeflate: false,
port: 65432, port: 65432,
}); });
wss.broadcast = (data) => {
wss.clients.forEach(client => {
if (client.readyState === WebSocket.OPEN) {
client.send(data);
}
});
};
// In this file you can include the rest of your app's specific main process // In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here. // code. You can also put them in separate files and require them here.
require('./websocket-events')(wss); require('./websocket-events')(wss);

View File

@ -9,18 +9,16 @@ const exiftool = new ExifTool();
module.exports = (wss) => { module.exports = (wss) => {
wss.on('connection', ws => { wss.on('connection', ws => {
ws.send(JSONMessage('server-log', 'Connected to client!')); ws.send(JSONMessage('server-log', 'Connected to client!'));
ws.on('message', (...args) => { ws.on('message', (...args) => {
const [type, message] = JSON.parse(args); const [type, message] = JSON.parse(args);
switch (type) { switch (type) {
case 'dropped-files': case 'dropped-files':
const filemap = []; const filemap = message.map(async file => {
message.forEach(async file => {
const tags = await getExifTags(file); const tags = await getExifTags(file);
console.info(tags); // console.info('Parsed tags', JSON.stringify(tags));
filemap[file] = tags; return JSON.parse(JSON.stringify(tags));
}); });
ws.send(JSONMessage('parsed-exif-tags', filemap)); wss.broadcast(JSONMessage('parsed-exif-tags', filemap));
break; break;
default: default:
@ -30,6 +28,6 @@ module.exports = (wss) => {
}); });
}; };
function getExifTags (imgPath) { async function getExifTags (imgPath) {
return exiftool.read(imgPath); await exiftool.read(imgPath);
} }

View File

@ -4657,10 +4657,6 @@ isomorphic-fetch@^2.1.1:
node-fetch "^1.0.1" node-fetch "^1.0.1"
whatwg-fetch ">=0.10.0" whatwg-fetch ">=0.10.0"
isomorphic-ws@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-4.0.0.tgz#7b528b238c920eeb3f5fe429ac416df669ea4cba"
isstream@~0.1.2: isstream@~0.1.2:
version "0.1.2" version "0.1.2"
resolved "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" resolved "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"