1
0
Fork 0
mirror of synced 2024-10-02 10:08:09 +13:00

Refactor client lib websocket usage to match other usages

This commit is contained in:
Andrew Kingston 2023-05-30 11:21:37 +01:00
parent 1db22d3965
commit cc53719c52
3 changed files with 3 additions and 17 deletions

View file

@ -41,7 +41,6 @@
"sanitize-html": "^2.7.0",
"screenfull": "^6.0.1",
"shortid": "^2.2.15",
"socket.io-client": "^4.5.1",
"svelte": "^3.49.0",
"svelte-apexcharts": "^1.0.2",
"svelte-flatpickr": "^3.1.0",

View file

@ -4,7 +4,7 @@ import {
notificationStore,
} from "./stores/index.js"
import { get } from "svelte/store"
import { io } from "socket.io-client"
import { createWebsocket } from "@budibase/frontend-core"
let socket
@ -18,20 +18,7 @@ export const initWebsocket = () => {
}
// Initialise connection
const tls = location.protocol === "https:"
const proto = tls ? "wss:" : "ws:"
const host = location.hostname
const port = location.port || (tls ? 443 : 80)
socket = io(`${proto}//${host}:${port}`, {
path: "/socket/client",
// Cap reconnection attempts to 3 (total of 15 seconds before giving up)
reconnectionAttempts: 3,
// Delay reconnection attempt by 5 seconds
reconnectionDelay: 5000,
reconnectionDelayMax: 5000,
// Timeout after 4 seconds so we never stack requests
timeout: 4000,
})
socket = createWebsocket("/socket/client")
// Event handlers
socket.on("plugin-update", data => {

View file

@ -22932,7 +22932,7 @@ socket.io-adapter@~2.5.2:
dependencies:
ws "~8.11.0"
socket.io-client@^4.5.1, socket.io-client@^4.6.1:
socket.io-client@^4.6.1:
version "4.6.1"
resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-4.6.1.tgz#80d97d5eb0feca448a0fb6d69a7b222d3d547eab"
integrity sha512-5UswCV6hpaRsNg5kkEHVcbBIXEYoVbMQaHJBXJCyEQ+CiFPV1NIOY0XOFWG4XR4GZcB8Kn6AsRs/9cy9TbqVMQ==