Skip to content

Commit

Permalink
start stop working
Browse files Browse the repository at this point in the history
  • Loading branch information
BitHighlander committed Oct 19, 2021
1 parent 467c958 commit f7eef17
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src-electron/main-process/electron-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,14 @@ const start_bridge = async function(event){
data:Buffer.from(resp).toString('hex')
}
console.log("output: ",output)
event.sender.send('dataSent',{ output })
res.status(200).json(output)
} else if(req.method === 'POST') {
let body = req.body
let msg = Buffer.from(body.data, "hex")
transport.writeChunk(msg)
console.log("input: ",msg)
event.sender.send('dataReceive',{ output:msg })
res.status(200).json({ })
} else {
throw Error('unhandled')
Expand Down Expand Up @@ -274,9 +276,9 @@ const start_bridge = async function(event){
}
}

ipcMain.on('onStopBridge', async (event, data) => {
const tag = TAG + ' | onStartBridge | '
try {
const stop_bridge = async function(event){
try{

event.sender.send('playSound',{ sound:'fail' })
console.log("server: ",server)
server.close(() => {
Expand All @@ -287,6 +289,17 @@ ipcMain.on('onStopBridge', async (event, data) => {
event.sender.send('setKeepKeyStatus',{ status:STATUS })
});

}catch(e){
console.error(e)
}
}


ipcMain.on('onStopBridge', async (event, data) => {
const tag = TAG + ' | onStartBridge | '
try {
stop_bridge(event)

} catch (e) {
console.error(tag, e)
}
Expand Down Expand Up @@ -316,6 +329,7 @@ ipcMain.on('onStartApp', async (event, data) => {
usb.on('detach', function(device) {
console.log("detach device: ",device)
event.sender.send('detach',{ device })
stop_bridge(event)
})

} catch (e) {
Expand Down

0 comments on commit f7eef17

Please sign in to comment.