merge
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import { io } from 'socket.io-client'
|
||||
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
|
||||
const apiDomain = import.meta.env.VITE_API_DOMAIN
|
||||
const wsConnection = import.meta.env.VITE_WS_CONNECTION
|
||||
|
||||
console.log('[main.js] api domain', apiDomain)
|
||||
console.log('[main.js] ws connection', wsConnection)
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
@@ -20,4 +17,3 @@ app.use(createPinia())
|
||||
app.use(router)
|
||||
|
||||
app.mount('#app')
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ export const useSocketStore = defineStore('websocket', () => {
|
||||
const lastError = ref(null)
|
||||
const currentGameId = ref(null)
|
||||
|
||||
const WS_URL = 'http://localhost:3000'
|
||||
const WS_URL = import.meta.env.VITE_WS_CONNECTION || 'ws://localhost:3000'
|
||||
|
||||
const connect = () => {
|
||||
if (socket.value?.connected) return
|
||||
@@ -27,13 +27,15 @@ export const useSocketStore = defineStore('websocket', () => {
|
||||
auth: { token: `Bearer ${token}` },
|
||||
reconnection: true,
|
||||
reconnectionAttempts: 5,
|
||||
reconnectionDelay: 1000
|
||||
reconnectionDelay: 1000,
|
||||
})
|
||||
|
||||
console.log('[WebSocket] Attempting to connect to', WS_URL)
|
||||
|
||||
socket.value.on('connect', () => {
|
||||
if (currentGameId.value) {
|
||||
console.log("Reconnected to socket. Rejoining game...");
|
||||
socket.emit("join-game", { gameId: currentGameId.value });
|
||||
console.log('Reconnected to socket. Rejoining game...')
|
||||
socket.emit('join-game', { gameId: currentGameId.value })
|
||||
}
|
||||
|
||||
connected.value = true
|
||||
@@ -122,8 +124,8 @@ export const useSocketStore = defineStore('websocket', () => {
|
||||
disconnect,
|
||||
joinGame,
|
||||
playCard,
|
||||
surrender,
|
||||
surrender,
|
||||
onTrickEnd,
|
||||
onGameOver
|
||||
onGameOver,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user