aboutsummaryrefslogtreecommitdiff
path: root/src/components/MultiplayerGrid.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/MultiplayerGrid.js')
-rw-r--r--src/components/MultiplayerGrid.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/components/MultiplayerGrid.js b/src/components/MultiplayerGrid.js
index 7cd3835..4260e9b 100644
--- a/src/components/MultiplayerGrid.js
+++ b/src/components/MultiplayerGrid.js
@@ -21,7 +21,7 @@ import { io } from 'socket.io-client';
import Box from './Box';
import './style.css';
-const socket = io("http://localhost:5000");
+const socket = io("https://ttt.vidhukant.com/api");
const MultiplayerGrid = (props) => {
// 0 is O, 1 is X, 2 is blank
@@ -36,9 +36,16 @@ const MultiplayerGrid = (props) => {
// host/join room
useEffect(() => {
if (isHost) {
+ const timeout = setTimeout(() => {
+ setMessage("Server Timed Out After 5 Seconds");
+ setShowMessage(true);
+ setTimeout(() => window.location.reload(), 3000)
+ }, 5000);
+
socket.emit("host");
socket.on("broadcast code", (code) => {
+ clearTimeout(timeout);
setMessage(`Game Code: ${code}`);
setShowMessage(true);
});
@@ -47,7 +54,7 @@ const MultiplayerGrid = (props) => {
setMessage("Opponent Joined")
setShowMessage(true)
setTimeout(() => setShowMessage(false), 3000)
- })
+ });
} else {
socket.emit("join", joinCode);