diff --git a/api/src/services/serverService.js b/api/src/services/serverService.js index d3484b8..73e8468 100644 --- a/api/src/services/serverService.js +++ b/api/src/services/serverService.js @@ -43,8 +43,8 @@ const checkServerHealth = async () => { }; const getAvailableServers = async () => { - return await GameServer.find({ status: "online" }).select( - "name url playersOnline maxPlayers", + return await GameServer.find({}).select( + "name url playersOnline status maxPlayers", ); }; const getServerConnectionDetails = async (serverId) => { diff --git a/client/src/context/SocketContext.jsx b/client/src/context/SocketContext.jsx index 46b5463..7771900 100644 --- a/client/src/context/SocketContext.jsx +++ b/client/src/context/SocketContext.jsx @@ -22,11 +22,9 @@ export const SocketProvider = ({ children }) => { } const userInfo = JSON.parse(localStorage.getItem("user")); - - console.log(url.replace("game-api", "socket.io")); const newSocket = io(url.replace("/game-api", ""), { - path: "/socket.io/", -auth: { token, username: userInfo?.username }, + path: "/socket.io/", + auth: { token, username: userInfo?.username }, transports: ["websocket"], reconnectionAttempts: 5, }); diff --git a/client/src/views/MainMenu/sections/ServerSection.css b/client/src/views/MainMenu/sections/ServerSection.css index 8ec6c74..70b48b2 100644 --- a/client/src/views/MainMenu/sections/ServerSection.css +++ b/client/src/views/MainMenu/sections/ServerSection.css @@ -1,4 +1,3 @@ -/* Основні контроллери (фільтри та кнопка Refresh) */ .server-controls { display: flex; justify-content: space-between; @@ -30,7 +29,6 @@ border-color: var(--primary-color); } -/* Контейнер списку серверів */ .server-list { max-height: calc(100vh - 350px); overflow-y: auto; @@ -41,7 +39,6 @@ padding: 10px; } -/* КАРТКА СЕРВЕРА */ .server-card { display: flex; justify-content: space-between; @@ -52,10 +49,8 @@ border-radius: 2px; border: 1px solid var(--border-color); position: relative; - /* Прибрано загальний transition для трансформацій */ } -/* Синя лінія зліва (фіксована, без виїзду) */ .server-card::before { content: ""; position: absolute; @@ -77,7 +72,6 @@ opacity: 1; } -/* Інформація про сервер */ .server-info { display: flex; align-items: center; @@ -101,9 +95,9 @@ background: rgba(0, 0, 0, 0.3); padding: 2px 8px; border-radius: 4px; + max-width: 100px; } -/* Індикатор статусу */ .status-indicator.online { width: 10px; height: 10px; @@ -126,7 +120,6 @@ } } -/* Заголовок секції */ .server-section-title { font-family: "Orbitron", sans-serif; font-size: 1.5rem; @@ -137,7 +130,6 @@ letter-spacing: 4px; } -/* Стани завантаження та порожнього списку */ .server-loading, .server-empty { text-align: center; @@ -206,7 +198,6 @@ display: flex; flex-direction: column; } -/* Адаптивність */ @media screen and (max-width: 600px) { .server-card { flex-direction: column; @@ -232,3 +223,43 @@ margin-bottom: 5px; } } + +.status-indicator { + width: 10px; + height: 10px; + border-radius: 50%; + margin-right: 15px; +} + +.status-indicator.online { + background: var(--success-color); + box-shadow: 0 0 10px var(--success-color); + animation: status-pulse 2s infinite ease-in-out; +} + +.status-indicator.offline { + background: #555; + box-shadow: none; + animation: none; + opacity: 0.5; +} + +@keyframes status-pulse { + 0%, + 100% { + opacity: 0.7; + transform: scale(1); + } + 50% { + opacity: 1; + transform: scale(1.15); + } +} + +@media screen and (max-width: 600px) { + .status-indicator.online, + .status-indicator.offline { + margin-right: 0; + margin-bottom: 5px; + } +} diff --git a/client/src/views/MainMenu/sections/ServerSection.jsx b/client/src/views/MainMenu/sections/ServerSection.jsx index 474ccba..d719c8d 100644 --- a/client/src/views/MainMenu/sections/ServerSection.jsx +++ b/client/src/views/MainMenu/sections/ServerSection.jsx @@ -19,7 +19,6 @@ const ServerSection = ({ onBack, onSelect }) => { const elapsedTime = Date.now() - startTime; const remainingTime = Math.max(0, 2000 - elapsedTime); await new Promise((resolve) => setTimeout(resolve, remainingTime)); - setServers(response.data); } catch (error) { console.error("Error fetching servers:", error); @@ -110,7 +109,9 @@ const ServerSection = ({ onBack, onSelect }) => { filteredServers.map((server) => (