fixing websocket, added auto refresh when frontend updated

This commit is contained in:
2025-06-19 18:52:00 +02:00
parent e6dc59ee1b
commit 4875601549
6 changed files with 57 additions and 1 deletions

20
ejs/footer.ejs Normal file
View File

@@ -0,0 +1,20 @@
<script>
let ws;
function connectWebSocket() {
const ws = new WebSocket((window.location.protocol === 'https:' ? 'wss://' : 'ws://') + window.location.host + window.location.pathname);
ws.onmessage = async (event) => {
if (event.data === 'update') {
location.reload();
}
};
ws.onclose = () => {
setTimeout(connectWebSocket, 5000);
};
}
connectWebSocket();
</script>

View File

@@ -53,4 +53,5 @@
<a href="/lobbies">Search Lobbies</a>
</div>
</body>
<%- include('footer') %>
</html>