Socket urlsi env dosyasında tanımlandı

This commit is contained in:
Kevser
2025-07-30 09:44:00 +03:00
parent 92d0a0dde7
commit 7cff75e82c
4 changed files with 25 additions and 22 deletions

View File

@ -1 +1,2 @@
VITE_API_URL=http://panelapi.cekilisevitest.gov.tr/ VITE_API_URL=http://panelapi.cekilisevitest.gov.tr/
VITE_SOCKET_URL=https://panelapi.cekilisevitest.gov.tr/uploadHub

View File

@ -1 +1,2 @@
VITE_API_URL=https://localhost:7241/ VITE_API_URL=https://localhost:7241/
VITE_SOCKET_URL=https://localhost:7241/uploadHub

View File

@ -1 +1,2 @@
VITE_API_URL=https://panelapi.cekilisevi.gov.tr/ VITE_API_URL=https://panelapi.cekilisevi.gov.tr/
VITE_SOCKET_URL=https://panelapi.cekilisevi.gov.tr/uploadHub

View File

@ -1,34 +1,34 @@
import * as signalR from "@microsoft/signalr"; import * as signalR from '@microsoft/signalr'
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from 'uuid'
let connection: signalR.HubConnection; let connection: signalR.HubConnection
let connectionId = ""; let connectionId = ''
export const connectToHub = async () => { export const connectToHub = async () => {
connection = new signalR.HubConnectionBuilder() connection = new signalR.HubConnectionBuilder()
.withUrl("https://panelapi.cekilisevi.gov.tr/uploadHub", { .withUrl(import.meta.env.VITE_SOCKET_URL, {
withCredentials: false // Bu zorunlu, yoksa cookie vs gönderilmez withCredentials: false // Bu zorunlu, yoksa cookie vs gönderilmez
}) // backend adresine göre düzenle }) // backend adresine göre düzenle
.withAutomaticReconnect() .withAutomaticReconnect()
.build(); .build()
await connection.start(); await connection.start()
connectionId = connection.connectionId || uuidv4(); // SignalR id'si ya da frontend'de de guid üretilebilir connectionId = connection.connectionId || uuidv4() // SignalR id'si ya da frontend'de de guid üretilebilir
return connectionId; return connectionId
}; }
export const onProgress = (callback: (data: any) => void) => { export const onProgress = (callback: (data: any) => void) => {
connection.on("ReceiveProgress", callback); connection.on('ReceiveProgress', callback)
}; }
export const onInsertProgress = (callback: (data: any) => void) => { export const onInsertProgress = (callback: (data: any) => void) => {
connection.on("ReceiveInsertProgress", callback); connection.on('ReceiveInsertProgress', callback)
}; }
export const onCompleted = (callback: (data: any) => void) => { export const onCompleted = (callback: (data: any) => void) => {
connection.on("ReceiveCompleted", callback); connection.on('ReceiveCompleted', callback)
}; }
export const onError = (callback: (data: any) => void) => { export const onError = (callback: (data: any) => void) => {
connection.on("ReceiveError", callback); connection.on('ReceiveError', callback)
}; }