-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
42 lines (33 loc) · 1002 Bytes
/
index.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
const { app } = require('electron')
const { ipcMain } = require('electron')
const path = require('path')
const menubar = require('menubar')
const scanner = require('./scanner')
const createServer = require('./server')
const Furbies = require('./furbies')
global.furbies = new Furbies()
console.log(process.env.DLC_FILE)
// https://github.com/maxogden/menubar#options
const opts = {
index: 'file://' + __dirname + '/index.html',
icon: './[email protected]',
preloadWindow: true
}
var mb = menubar(opts)
app.on('window-all-closed', () => {
app.quit()
})
ipcMain.on('pair', (event, uuid) => {
global.furbies.selected = uuid
})
ipcMain.on('unpair', (event, uuid) => {
global.furbies.selected = null
})
mb.on('ready', function ready () {
console.log('Waiting for furbies to connect')
scanner((peripheral, fluff) => {
global.furbies.add(peripheral.uuid, fluff)
mb.window.webContents.send('furby-connected', {fluff: fluff, uuid: peripheral.uuid});
})
createServer()
})