Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
console.log('Connecting to link-server...')
const linkAPI = new LinkAPI(switchSwitchableBlock)
let isBusy = false
const ws = new WebSocket('wss://comfortapp.online:3301/main')
ws.addEventListener('open', () => console.log('Connection with link-server established'))
ws.addEventListener('message', async (message) => {
console.log('Received new link-command: ', message.data)
if (isBusy) {
console.log('Previous link-command is not performed yet, skipping new one')
return
}
isBusy = true
try {
const data = JSON.parse(message.data)
await linkAPI[data.method](data)
} catch (exception) {
console.log('Unable to perform link-command')
console.log(exception)
}
isBusy = false
})
})