-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.js
33 lines (29 loc) · 926 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const {app, BrowserWindow} = require('electron')
const service = require('./proto/chat_grpc_pb')
const chat = require('./proto/chat_pb')
const grpc = require('grpc')
function createWindow() {
// Create the browser window.
let win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
win.removeMenu();
// Open the DevTools.
win.webContents.openDevTools({
mode: "detach"
})
// and load the index.html of the app.
win.loadFile('index.html')
let client = new service.ChatServerClient('localhost:11912', grpc.credentials.createInsecure())
let note = new chat.Note()
note.setMessage('Hello from electron')
console.log('sending note to server')
client.sendNote(note, function(err, response) {
console.log('received reply', response);
});
}
app.on('ready', createWindow)