Electron machine api tests (#3534)
* start Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * Look at this (photo)Graph *in the voice of Nickelback* * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * hide on webapp Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix machine-api Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
19
src/main.ts
19
src/main.ts
@ -131,8 +131,6 @@ ipcMain.handle('kittycad', (event, data) => {
|
||||
)(data.args)
|
||||
})
|
||||
|
||||
const SERVICE_NAME = '_machine-api._tcp.local.'
|
||||
|
||||
ipcMain.handle('find_machine_api', () => {
|
||||
const timeoutAfterMs = 5000
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -144,8 +142,19 @@ ipcMain.handle('find_machine_api', () => {
|
||||
resolve(null)
|
||||
})
|
||||
console.log('Looking for machine API...')
|
||||
bonjourEt.find({ type: SERVICE_NAME }, (service: Service) => {
|
||||
resolve(service.fqdn)
|
||||
})
|
||||
bonjourEt.find(
|
||||
{ protocol: 'tcp', type: 'machine-api' },
|
||||
(service: Service) => {
|
||||
console.log('Found machine API!', JSON.stringify(service))
|
||||
if (!service.addresses || service.addresses?.length === 0) {
|
||||
console.log('No addresses found for machine API!')
|
||||
return resolve(null)
|
||||
}
|
||||
const ip = service.addresses[0]
|
||||
const port = service.port
|
||||
// We want to return the ip address of the machine API.
|
||||
resolve(`${ip}:${port}`)
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user