8 lines
365 B
JavaScript
8 lines
365 B
JavaScript
'use strict';
|
|
|
|
function startWebSocket(socketPath, messageHandler) {
|
|
const protocolPrefix = (window.location.protocol === 'https:') ? 'wss:' : 'ws:';
|
|
const webSocket = new RobustWebSocket(`${protocolPrefix}//${location.host}${socketPath}`);
|
|
webSocket.onmessage = messageHandler ? messageHandler : () => {};
|
|
Alpine.data.buzzerWebSocket = webSocket
|
|
}
|