mirror of
https://github.com/muerwre/muerwre.github.io.git
synced 2025-04-25 19:06:41 +07:00
commit bf74240684
Author: Fedor Katurov <gotham48@gmail.com> Date: Wed Nov 9 16:15:51 2022 +0600 vault backup: 2022-11-09 16:15:51
This commit is contained in:
parent
07112d2a58
commit
ab759c37d3
189 changed files with 285 additions and 240 deletions
1
nuxt/web-socket.3029b5ee.js
Normal file
1
nuxt/web-socket.3029b5ee.js
Normal file
|
@ -0,0 +1 @@
|
|||
import{M as u,N as i}from"./entry.fb9e6b9e.js";const n={log:(...t)=>console.log("[Content]",...t),warn:(...t)=>console.warn("[Content]",...t)};let e;function g(){if(!window.WebSocket){n.warn("Could not enable hot reload, your browser does not support WebSocket.");return}const t=o=>{try{if(!JSON.parse(o.data))return;i()}catch{}},s=()=>n.log("WS connected!"),a=o=>{switch(o.code){case"ECONNREFUSED":r(!0);break;default:n.warn("WS Error:",o);break}},l=o=>{o.code===1e3||o.code===1005?n.log("WS closed!"):r(!0)},r=(o=!1)=>{if(o){n.log("WS reconnecting.."),setTimeout(r,1e3);return}if(e){try{e.close()}catch{}e=void 0}const c=`${u().public.content.wsUrl}ws`;n.log(`WS connect to ${c}`),e=new WebSocket(c),e.onopen=s,e.onmessage=t,e.onerror=a,e.onclose=l};return r(),{connect:r}}export{g as useContentWebSocket};
|
Loading…
Add table
Add a link
Reference in a new issue