-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.js
60 lines (46 loc) · 1.81 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const {app, BrowserWindow} = require('electron');
const url = require('url');
const path = require('path');
const ipc = require('electron').ipcMain;
let mainWindow, serverWindow;
global.devMode = (process.argv.indexOf("--dev") > -1);
global.appRootDir = path.resolve(__dirname);
global.appLibsDir = path.resolve(__dirname + '/3rdparty');
global.appModelsDir = path.resolve(__dirname + '/models');
// Serves as the bottom layer of the application. Every new render is connected to this one.
// The communication is organized as follows:
// Everyone talks to the server through
// ipc.send('to-server', ****command**** );
// This process transmits all messages of such type to the server...
function createWindow() {
console.log('===== WELCOME TO VISA: ViSP Simulation App =====');
mainWindow = new BrowserWindow({
width: 1400,
height: 600,
webPreferences: {
nativeWindowOpen: true
},
icon: path.join(__dirname, 'icons/png/64x64.png')
})
mainWindow.maximize();
mainWindow.loadURL('file://' + __dirname + '/src/index.html');
if (global.devMode) mainWindow.toggleDevTools();
mainWindow.on('close', (e) => { app.quit(); });
serverWindow = new BrowserWindow({show: false}) ;
serverWindow.loadURL('file://' + __dirname + '/src/server.html');
}
ipc.on('to-server', function(event, arg) {
//console.log('Command to server received');
//console.log(typeof arg.data);
serverWindow.webContents.send(arg.cmd,arg.data);
});
ipc.on('cmd-received', function(event, arg) {
mainWindow.webContents.send('command',arg);
});
ipc.on('send-to-log', function(event, arg) {
console.log('SERVER LOG: ' + arg);
});
ipc.on('alert', function(event, arg) {
mainWindow.webContents.send('alert',arg);
});
app.on('ready', createWindow)