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 socketio = require('socket.io-client')
|
||||||
|
|
||||||
|
|
||||||
const socket = socketio('ws://184.83.153.182:5000/')
|
let win = null
|
||||||
socket.emit('join-notifications')
|
|
||||||
|
|
||||||
socket.on('connect-notifications', () => {
|
let getlock = app.requestSingleInstanceLock()
|
||||||
console.log('connected to notification stream')
|
|
||||||
showNotification('Websocket Connected', "You successfully connected to the websocket.")
|
|
||||||
})
|
|
||||||
|
|
||||||
socket.on('send-notification', (data) => {
|
if(!getlock){
|
||||||
showNotification(data.title, data.body)
|
app.quit()
|
||||||
})
|
} else {
|
||||||
|
if (win) {
|
||||||
|
if (win.isMinimized()) win.restore()
|
||||||
|
win.focus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const createWindow = () => {
|
const createWindow = () => {
|
||||||
if (!tray){
|
if (!tray){
|
||||||
@ -76,6 +77,18 @@ app.whenReady().then(() => {
|
|||||||
createWindow()
|
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) => {
|
app.on('window-all-closed', (event) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user