gRPC is added

This commit is contained in:
병준 박 2019-05-12 19:59:09 +09:00
parent e9cf4adac2
commit e40776c47c
4 changed files with 1826 additions and 13 deletions

View File

@ -10,5 +10,6 @@
"git.ignoreLimitWarning": true, "git.ignoreLimitWarning": true,
"prettier.singleQuote": true, "prettier.singleQuote": true,
"debug.node.autoAttach": "on" "debug.node.autoAttach": "on",
"cSpell.words": ["grpc", "proto"]
} }

1802
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"scripts": { "scripts": {
"electron": "tsc --p ./ && electron ." "electron": "tsc --project ./ && electron . --serve"
}, },
"dependencies": { "dependencies": {
"electron-devtools-installer": "^2.2.4", "electron-devtools-installer": "^2.2.4",
@ -22,7 +22,7 @@
"rxjs": "^6.5.2" "rxjs": "^6.5.2"
}, },
"devDependencies": { "devDependencies": {
"@odds-crawler/proto": "^0.0.4", "@odds-crawler/proto": "^0.0.6",
"@types/google-protobuf": "^3.2.7", "@types/google-protobuf": "^3.2.7",
"@types/node": "^8.9.4", "@types/node": "^8.9.4",
"electron": "^5.0.0", "electron": "^5.0.0",

View File

@ -4,7 +4,12 @@ import * as url from 'url';
import * as fs from 'fs'; import * as fs from 'fs';
import * as grpc from 'grpc'; import * as grpc from 'grpc';
import { CDPServiceClient } from '@odds-crawler/proto/cdp/cdp.service_grpc_pb'; import * as CDPServiceProto from '@odds-crawler/proto/cdp/cdp.service_pb';
import * as CDPServiceGRpcProto from '@odds-crawler/proto/cdp/cdp.service_grpc_pb';
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
const appDir = path.join(__dirname, `../../dist/odds-crawler-frontend-app`);
let mainWindow: BrowserWindow; let mainWindow: BrowserWindow;
@ -28,15 +33,12 @@ function createWindow() {
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({
width: 800, width: 800,
height: 600, height: 600,
webPreferences: { nodeIntegration: true } webPreferences: { nodeIntegration: false }
}); });
mainWindow.loadURL( mainWindow.loadURL(
url.format({ url.format({
pathname: path.join( pathname: path.join(appDir, `/index.html`),
__dirname,
`../../dist/odds-crawler-frontend-app/index.html`
),
protocol: 'file:', protocol: 'file:',
slashes: true slashes: true
}) })
@ -48,10 +50,24 @@ function createWindow() {
mainWindow = null; mainWindow = null;
}); });
let cdpServiceClient = new CDPServiceClient( let cdpServiceClient = new CDPServiceGRpcProto.CDPServiceClient(
'localhost:50051', 'localhost:50051',
grpc.credentials.createInsecure() grpc.credentials.createInsecure()
); );
// let req: CDPServiceProto.NavigateRequest;
// let res: CDPServiceProto.NavigateReply;
// req = new CDPServiceProto.NavigateRequest();
// req.setUrl('https://www.google.com');
// cdpServiceClient.navigate(req, (err, res) => {
// if (err) {
// console.log(err);
// return;
// }
// console.log(res);
// });
} }
ipcMain.on('getFiles', (event, arg) => { ipcMain.on('getFiles', (event, arg) => {