gRPC is added

This commit is contained in:
병준 박 2019-05-12 15:03:32 +09:00
parent 7fb66f3358
commit e9cf4adac2
3 changed files with 2208 additions and 69 deletions

2226
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -11,10 +11,25 @@
"scripts": { "scripts": {
"electron": "tsc --p ./ && electron ." "electron": "tsc --p ./ && electron ."
}, },
"dependencies": {}, "dependencies": {
"electron-devtools-installer": "^2.2.4",
"electron-log": "^3.0.5",
"electron-window-state": "^5.0.3",
"file-uri-to-path": "^1.0.0",
"file-url": "^3.0.0",
"fs-extra": "^7.0.1",
"grpc": "^1.20.3",
"rxjs": "^6.5.2"
},
"devDependencies": { "devDependencies": {
"@types/electron": "^1.6.10", "@odds-crawler/proto": "^0.0.4",
"@types/google-protobuf": "^3.2.7",
"@types/node": "^8.9.4",
"electron": "^5.0.0", "electron": "^5.0.0",
"electron-builder": "^20.40.2",
"electron-connect": "^0.6.3",
"electron-debug": "^3.0.0",
"google-protobuf": "^3.8.0-rc.1",
"ts-node": "^8.1.0", "ts-node": "^8.1.0",
"tslint": "^5.16.0", "tslint": "^5.16.0",
"typescript": "^3.4.5" "typescript": "^3.4.5"

View File

@ -2,25 +2,36 @@ import { app, BrowserWindow, ipcMain } from 'electron';
import * as path from 'path'; import * as path from 'path';
import * as url from 'url'; import * as url from 'url';
import * as fs from 'fs'; import * as fs from 'fs';
import * as grpc from 'grpc';
let win: BrowserWindow; import { CDPServiceClient } from '@odds-crawler/proto/cdp/cdp.service_grpc_pb';
let mainWindow: BrowserWindow;
app.on('ready', createWindow); app.on('ready', createWindow);
app.on('activate', () => { app.on('activate', () => {
if (win === null) { if (null === mainWindow) {
createWindow(); createWindow();
} }
}); });
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if ('darwin' !== process.platform) {
app.quit();
}
});
function createWindow() { function createWindow() {
win = new BrowserWindow({ mainWindow = new BrowserWindow({
width: 800, width: 800,
height: 600, height: 600,
webPreferences: { nodeIntegration: true } webPreferences: { nodeIntegration: true }
}); });
win.loadURL( mainWindow.loadURL(
url.format({ url.format({
pathname: path.join( pathname: path.join(
__dirname, __dirname,
@ -31,14 +42,19 @@ function createWindow() {
}) })
); );
win.webContents.openDevTools(); mainWindow.webContents.openDevTools();
win.on('closed', () => { mainWindow.on('closed', () => {
win = null; mainWindow = null;
}); });
let cdpServiceClient = new CDPServiceClient(
'localhost:50051',
grpc.credentials.createInsecure()
);
} }
ipcMain.on('getFiles', (event, arg) => { ipcMain.on('getFiles', (event, arg) => {
const files = fs.readdirSync(__dirname); const files = fs.readdirSync(__dirname);
win.webContents.send('getFilesResponse', files); mainWindow.webContents.send('getFilesResponse', files);
}); });