fix issues for websocket merge

merge-socket
adriano 2024-08-29 18:09:00 -03:00
parent 1f8d5eb29b
commit 0a031bd9a8
5 changed files with 22 additions and 21 deletions

View File

@ -59,14 +59,14 @@ export const initIO = (httpServer: Server): SocketIO => {
io = new SocketIO(httpServer, {
cors: {
origin: "*",
allowedHeaders: ["my-custom-header"],
credentials: true
origin: process.env.FRONTEND_URL,
//allowedHeaders: ["my-custom-header"],
//credentials: true
},
maxHttpBufferSize: 1e8,
pingInterval: 25000,
pingTimeout: 60000,
adapter: createAdapter(pubClient, subClient)
// pingInterval: 25000,
// pingTimeout: 60000,
// adapter: createAdapter(pubClient, subClient)
});

View File

@ -6,4 +6,4 @@ app.use(express.static(path.join(__dirname, "build")));
app.get("/*", function (req, res) {
res.sendFile(path.join(__dirname, "build", "index.html"));
});
app.listen(3331);
app.listen(3333);

View File

@ -152,7 +152,7 @@ const TicketsManager = () => {
const [openCount, setOpenCount] = useState(0)
const [pendingCount, setPendingCount] = useState(0)
const userQueueIds = user.queues.map((q) => q.id)
const userQueueIds = user?.queues?.map((q) => q?.id)
const [selectedQueueIds, setSelectedQueueIds] = useState(userQueueIds || [])
const [showContentSearch, setShowContentSearch] = useState(false)
@ -177,9 +177,9 @@ const TicketsManager = () => {
}, [setting])
useEffect(() => {
if (user.profile.toUpperCase() === "ADMIN" ||
user.profile.toUpperCase() === "SUPERVISOR" ||
user.profile.toUpperCase() === "MASTER") {
if (user?.profile?.toUpperCase() === "ADMIN" ||
user?.profile?.toUpperCase() === "SUPERVISOR" ||
user?.profile?.toUpperCase() === "MASTER") {
setShowAllTickets(true)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
@ -202,11 +202,11 @@ const TicketsManager = () => {
if (tickets.length > 0) {
const now = new Date()
const differenceTime = tickets?.map(ticket => {
const createdAt = new Date(ticket.createdAt)
const createdAt = new Date(ticket?.createdAt)
const difference = now - createdAt
return difference
})
const sumDifferences = differenceTime.reduce((total, difference) => total + difference, 0)
const sumDifferences = differenceTime?.reduce((total, difference) => total + difference, 0)
const averageTimeMilliseconds = sumDifferences / tickets?.length
let hours = Math.floor(averageTimeMilliseconds / 3600000)
const minutes = Math.floor((averageTimeMilliseconds % 3600000) / 60000)

View File

@ -1,7 +1,7 @@
import axios from "axios";
const api = axios.create({
baseURL: process.env.REACT_APP_BACKEND_URL + "/api",
baseURL: process.env.REACT_APP_BACKEND_URL,
withCredentials: true,
});

View File

@ -3,11 +3,12 @@ import { io } from 'socket.io-client';
// "undefined" means the URL will be computed from the `window.location` object
const URL = process.env.REACT_APP_BACKEND_URL
export const socket = io(URL, {
path: "/api-ws/socketio",
withCredentials: true,
extraHeaders: {
"my-custom-header": "abcd"
},
export const socket = io(URL,
//{
// withCredentials: true,
// extraHeaders: {
// "my-custom-header": "abcd"
// },
// transports: ['websocket', 'polling']
});
//}
);