Refactor: swap the order to poll and than upgrade to WS
This commit is contained in:
parent
fa9f1fcefc
commit
28207bcd41
1 changed files with 2 additions and 8 deletions
|
|
@ -51,7 +51,7 @@ export const useSocketStore = defineStore('socket', () => {
|
||||||
|
|
||||||
const connect = () => {
|
const connect = () => {
|
||||||
const opts = {
|
const opts = {
|
||||||
transports: ['websocket', 'polling'],
|
transports: ['polling', 'websocket'],
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
reconnection: true,
|
reconnection: true,
|
||||||
reconnectionAttempts: 50,
|
reconnectionAttempts: 50,
|
||||||
|
|
@ -72,13 +72,7 @@ export const useSocketStore = defineStore('socket', () => {
|
||||||
connectionStatus.value = 'connecting';
|
connectionStatus.value = 'connecting';
|
||||||
socket.value = io(url, opts)
|
socket.value = io(url, opts)
|
||||||
|
|
||||||
on("connect_error", (e: any) => {
|
on("connect_error", (e: any) => console.error("Socket connection error:", e));
|
||||||
if (!socket.value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.error("Socket connection error:", e);
|
|
||||||
socket.value.io.opts.transports = ["polling", "websocket"];
|
|
||||||
});
|
|
||||||
|
|
||||||
on('connect', () => {
|
on('connect', () => {
|
||||||
isConnected.value = true
|
isConnected.value = true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue