Add SingleInstanceLock

This commit is contained in:
Jadowyne Ulve 2025-05-22 16:58:00 -05:00
parent b06352370a
commit a07e50f0ea

31
main.js
View File

@ -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) => {