@ubuilder/websocket
Version:
UBuilder WebSocket
2 lines (1 loc) • 459 B
JavaScript
;var o=require("@stomp/stompjs"),t={options:{websocketUrl:null},install:function(t,e){if(this.options=Object.assign(this.options,e),e.websocketUrl){var s=new o.Client({brokerURL:this.options.websocketUrl,reconnectDelay:500,onConnect:function(o){s.subscribe("/topic/public",(function(o){s.onmessage&&s.onmessage(o.body)}))}});s.send=function(o){s.publish({destination:"/ws/send",body:o})},s.activate(),t.prototype.$webSocket=s}}};module.exports=t;