added websocket
This commit is contained in:
35
src/misc/ChatGpt.js
Normal file
35
src/misc/ChatGpt.js
Normal 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)*/
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user