This commit is contained in:
@@ -4,6 +4,7 @@ import { io } from 'socket.io-client'
|
||||
|
||||
export const useSignaling = createSharedComposable(() => {
|
||||
const toast = useToast()
|
||||
const { me } = useAuth()
|
||||
|
||||
const socket = shallowRef<Socket>()
|
||||
|
||||
@@ -44,8 +45,16 @@ export const useSignaling = createSharedComposable(() => {
|
||||
toast.add({ severity: 'error', summary: 'Disconnected', closable: false, life: 1000 })
|
||||
}, { immediate: true })
|
||||
|
||||
watch(me, (me) => {
|
||||
if (!me) {
|
||||
socket.value?.close()
|
||||
socket.value = undefined
|
||||
}
|
||||
})
|
||||
|
||||
onScopeDispose(() => {
|
||||
socket.value?.close()
|
||||
socket.value = undefined
|
||||
})
|
||||
|
||||
function connect() {
|
||||
@@ -53,9 +62,13 @@ export const useSignaling = createSharedComposable(() => {
|
||||
return
|
||||
|
||||
socket.value = io('https://api.koptilnya.xyz/webrtc', {
|
||||
// socket.value = io('http://127.0.0.1:4000/webrtc', {
|
||||
// socket.value = io('http://localhost:4000/webrtc', {
|
||||
path: '/chad/ws',
|
||||
transports: ['websocket'],
|
||||
withCredentials: true,
|
||||
auth: {
|
||||
userId: me.value!.id,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user