Add SingleInstanceLock
This commit is contained in:
parent
b06352370a
commit
a07e50f0ea
31
main.js
31
main.js
@ -4,17 +4,18 @@ const path = require('node:path')
|
||||
const socketio = require('socket.io-client')
|
||||
|
||||
|
||||
const socket = socketio('ws://184.83.153.182:5000/')
|
||||
socket.emit('join-notifications')
|
||||
let win = null
|
||||
|
||||
socket.on('connect-notifications', () => {
|
||||
console.log('connected to notification stream')
|
||||
showNotification('Websocket Connected', "You successfully connected to the websocket.")
|
||||
})
|
||||
let getlock = app.requestSingleInstanceLock()
|
||||
|
||||
socket.on('send-notification', (data) => {
|
||||
showNotification(data.title, data.body)
|
||||
})
|
||||
if(!getlock){
|
||||
app.quit()
|
||||
} else {
|
||||
if (win) {
|
||||
if (win.isMinimized()) win.restore()
|
||||
win.focus()
|
||||
}
|
||||
}
|
||||
|
||||
const createWindow = () => {
|
||||
if (!tray){
|
||||
@ -76,6 +77,18 @@ app.whenReady().then(() => {
|
||||
createWindow()
|
||||
}
|
||||
})
|
||||
const socket = socketio('ws://184.83.153.182:5000/')
|
||||
socket.emit('join-notifications')
|
||||
|
||||
socket.on('connect-notifications', () => {
|
||||
console.log('connected to notification stream')
|
||||
showNotification('Websocket Connected', "You successfully connected to the websocket.")
|
||||
})
|
||||
|
||||
socket.on('send-notification', (data) => {
|
||||
showNotification(data.title, data.body)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
app.on('window-all-closed', (event) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user