-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
49 lines (40 loc) · 961 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const { app, BrowserWindow, ipcMain } = require('electron')
const path = require("path");
const Server = require('./src/server/server')
const createWindow = () => {
const win = new BrowserWindow({
width: 800,
height: 600,
resizable: false,
title: 'Togethr',
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
win.setMenuBarVisibility(false)
win.loadFile('index.html')
}
app.whenReady().then(() => {
createWindow()
})
app.on('window-all-closed', () => {
app.quit()
})
let serverState = false
let server
ipcMain.on('start-stop-server', (event, arg) => {
if(serverState){
server.stopServer()
delete server
console.log('Stopping server.');
}else{
server = new Server()
server.startServer()
console.log('Starting server.');
}
serverState = !serverState
console.log(serverState);
})
ipcMain.on('server-state', (event, arg) => {
event.returnValue = serverState
})