Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ba83ad538 |
@@ -20,7 +20,9 @@ export default function RootLayout({
|
||||
<html lang="en">
|
||||
<body className="bg-gray-900 text-white antialiased">
|
||||
<QueryProvider>
|
||||
<WebSocketProvider>
|
||||
<WebSocketProvider
|
||||
websocketURL={process.env.NEXT_PUBLIC_WEBSOCKET_URL || 'ws://localhost:3000/ws'}
|
||||
>
|
||||
<SteamCMDProvider>
|
||||
<ServerCreationPopupProvider>
|
||||
{children}
|
||||
|
||||
@@ -57,9 +57,9 @@ export class WebSocketClient {
|
||||
private associatedServerId: string | null = null;
|
||||
private baseUrl: string;
|
||||
|
||||
constructor(token: string) {
|
||||
constructor(token: string, url: string) {
|
||||
this.token = token;
|
||||
this.baseUrl = process.env.NEXT_PUBLIC_WEBSOCKET_URL || 'ws://localhost:3000/ws';
|
||||
this.baseUrl = url;
|
||||
}
|
||||
|
||||
connect(): Promise<void> {
|
||||
|
||||
@@ -30,9 +30,10 @@ export function useWebSocket() {
|
||||
|
||||
interface WebSocketProviderProps {
|
||||
children: ReactNode;
|
||||
websocketURL: string;
|
||||
}
|
||||
|
||||
export function WebSocketProvider({ children }: WebSocketProviderProps) {
|
||||
export function WebSocketProvider({ children, websocketURL }: WebSocketProviderProps) {
|
||||
const [client, setClient] = useState<WebSocketClient | null>(null);
|
||||
const [isConnected, setIsConnected] = useState(false);
|
||||
const [connectionStatus, setConnectionStatus] = useState<
|
||||
@@ -50,7 +51,7 @@ export function WebSocketProvider({ children }: WebSocketProviderProps) {
|
||||
client.disconnect();
|
||||
}
|
||||
|
||||
const newClient = new WebSocketClient(token);
|
||||
const newClient = new WebSocketClient(token, websocketURL);
|
||||
|
||||
const statusHandler: ConnectionStatusHandler = (status, error) => {
|
||||
setConnectionStatus(status);
|
||||
|
||||
Reference in New Issue
Block a user