-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelectron.js
More file actions
85 lines (70 loc) · 2.17 KB
/
Copy pathelectron.js
File metadata and controls
85 lines (70 loc) · 2.17 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* jshint node: true */
'use strict';
const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const emberAppLocation = `file://${__dirname}/dist/index.html`;
let mainWindow = null;
var EventEmitter = require('./services/event-emitter.js');
var Bluetooth = require('./services/bluetooth.js');
var eventEmitter = null;
var bluetooth = new Bluetooth();
electron.crashReporter.start();
app.on('window-all-closed', function onWindowAllClosed() {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('ready', function onReady() {
mainWindow = new BrowserWindow({
width: 1024,
height: 760
});
eventEmitter = new EventEmitter(mainWindow);
eventEmitter.on('test', function(res, data) {
console.log(data);
eventEmitter.emit('test', JSON.stringify({
data: {
type: 'test',
id: '001',
attributes: {
message: 'test message',
info: data
}
}
}));
});
eventEmitter.on('bluetooth-list', function(res, data) {
console.log(data);
bluetooth.list(function(data) {
eventEmitter.emit('bluetooth-list', {
data: {
type: 'bluetooth-list',
id: '001',
attributes: {
message: 'List of the Bluetooth ports',
info: data
}
}
});
});
});
delete mainWindow.module;
// If you want to open up dev tools programmatically, call
mainWindow.openDevTools();
// By default, we'll open the Ember App by directly going to the
// file system.
//
// Please ensure that you have set the locationType option in the
// config/environment.js file to 'hash'. For more information,
// please consult the ember-electron readme.
mainWindow.loadURL(emberAppLocation);
// If a loading operation goes wrong, we'll send Electron back to
// Ember App entry point
mainWindow.webContents.on('did-fail-load', () => {
mainWindow.loadURL(emberAppLocation);
});
mainWindow.on('closed', () => {
mainWindow = null;
});
});