/*! phoscon-app 2024-05-27 */

function wsOnMessage(msg){var data=JSON.parse(msg.data);app.ws&&app.ws.rxCounter++,"event"===data.t&&app.api.trigger("event",data)}function wsOnOpen(e){console.log("websocket connected:",app.ws.url)}function initWebSocket(){app.isWebSocketAlive=function(){return!(!app.ws||app.ws.readyState!==WebSocket.OPEN)},function check(){app.ws&&app.ws.readyState===WebSocket.CLOSED&&(delete app.ws,app.ws=void 0);var port=app.config?app.config.get("websocketport"):void 0,host=app.session.gw.split(":")[0];if(port&&!app.ws){const prot="http:"===location.protocol?"ws://":"wss://";app.ws=new WebSocket(prot+host+":"+port),app.ws.rxCounter=0,app.ws.onmessage=wsOnMessage,app.ws.onopen=wsOnOpen}setTimeout(check,app.ws?1e4:1e3)}()}