websocket and api updates
This commit is contained in:
parent
318fb775a4
commit
209f536693
|
|
@ -10,7 +10,7 @@ import { useWebsocketLottery } from "@/hooks/useWebSocketLottery";
|
||||||
import Confetti from "../common/Confetti";
|
import Confetti from "../common/Confetti";
|
||||||
import { AnimatePresence, motion } from "framer-motion";
|
import { AnimatePresence, motion } from "framer-motion";
|
||||||
|
|
||||||
const WEBSOCKET_URL = "wss://sms.turkmentv.gov.tm/ws/lottery?dst=0506";
|
const WEBSOCKET_URL = "wss://sms.turkmentv.gov.tm/ws/lottery?dst=";
|
||||||
const SLOT_COUNTER_DURATION = 30000;
|
const SLOT_COUNTER_DURATION = 30000;
|
||||||
|
|
||||||
const LotteryWinnersSection = ({
|
const LotteryWinnersSection = ({
|
||||||
|
|
@ -36,7 +36,9 @@ const LotteryWinnersSection = ({
|
||||||
>([]); // Queue for incoming WebSocket messages
|
>([]); // Queue for incoming WebSocket messages
|
||||||
const [isProcessing, setIsProcessing] = useState<boolean>(false); // Track if a message is being processed
|
const [isProcessing, setIsProcessing] = useState<boolean>(false); // Track if a message is being processed
|
||||||
|
|
||||||
const { wsStatus, subscribeToMessages } = useWebsocketLottery(WEBSOCKET_URL);
|
const { wsStatus, subscribeToMessages } = useWebsocketLottery(
|
||||||
|
`${WEBSOCKET_URL}${lotteryData?.data.sms_number}`
|
||||||
|
);
|
||||||
|
|
||||||
// Simulate WebSocket messages for testing
|
// Simulate WebSocket messages for testing
|
||||||
const simulateMessage = () => {
|
const simulateMessage = () => {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ export const useWebsocketLottery = (url: string) => {
|
||||||
if (!isMounted) return;
|
if (!isMounted) return;
|
||||||
|
|
||||||
console.log("✅ WebSocket connected");
|
console.log("✅ WebSocket connected");
|
||||||
|
console.log("WebSocket url", url);
|
||||||
setWsStatus("connected");
|
setWsStatus("connected");
|
||||||
if (reconnectTimeoutRef.current)
|
if (reconnectTimeoutRef.current)
|
||||||
clearTimeout(reconnectTimeoutRef.current);
|
clearTimeout(reconnectTimeoutRef.current);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ export interface ILotteryWinner {
|
||||||
}
|
}
|
||||||
export interface ILotteryRule {
|
export interface ILotteryRule {
|
||||||
title: string;
|
title: string;
|
||||||
content: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ILotteryData {
|
export interface ILotteryData {
|
||||||
|
|
@ -18,6 +17,7 @@ export interface ILotteryData {
|
||||||
start_time: string;
|
start_time: string;
|
||||||
end_time: string;
|
end_time: string;
|
||||||
sms_code: string;
|
sms_code: string;
|
||||||
|
sms_number: string;
|
||||||
winners: ILotteryWinner[];
|
winners: ILotteryWinner[];
|
||||||
rules: ILotteryRule[] | null;
|
rules: ILotteryRule[] | null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue