added websocket

This commit is contained in:
MoonDev
2025-05-04 22:25:40 +03:00
parent b936636af1
commit a249143cde
4 changed files with 176 additions and 24 deletions

35
src/misc/ChatGpt.js Normal file
View File

@@ -0,0 +1,35 @@
import io from "socket.io-client";
import { useEffect } from "react";
//
//const socket = io("http://localhost:5000"); // Подключение к серверу
export function NewRequest(formData, addMessage, setGenerationProcess, setStage, setLoading) {
var initial = false;
const socket = io("http://localhost:5000",{transports:["websocket"]});
socket.on("connect", () => {
if(!initial){
initial = true;
socket.emit("new_problem",formData)
}
});
/*
setTimeout(() => {
setStage(1);
setLoading(false);
addMessage(formData.message);
setTimeout(() => {
addMessage("Ваш вопрос отправлен в службу поддержки. Уже подбираем варианты решения проблемы...", false);
setTimeout(() => {
setGenerationProcess(true);
}, 500);
}, 500);
}, 500)*/
}