mirror of
https://github.com/mizanxali/uno-online
synced 2025-12-06 10:13:27 +00:00
Set up socketio server-client connection
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import PACK_OF_CARDS from '../utils/packOfCards'
|
||||
import shuffleArray from '../utils/shuffleArray'
|
||||
import io from 'socket.io-client'
|
||||
|
||||
//NUMBER CODES FOR ACTION CARDS
|
||||
//SKIP - 404
|
||||
@@ -8,8 +9,23 @@ import shuffleArray from '../utils/shuffleArray'
|
||||
//WILD - 300
|
||||
//DRAW 4 WILD - 600
|
||||
|
||||
let socket
|
||||
const ENDPOINT = 'http://localhost:5000'
|
||||
|
||||
const Game = () => {
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const connectionOptions = {
|
||||
"forceNew" : true,
|
||||
"reconnectionAttempts": "Infinity",
|
||||
"timeout" : 10000,
|
||||
"transports" : ["websocket"]
|
||||
}
|
||||
socket = io.connect(ENDPOINT, connectionOptions)
|
||||
console.log(socket);
|
||||
}, [])
|
||||
|
||||
//initialize game state
|
||||
const [gameOver, setGameOver] = useState(true)
|
||||
const [winner, setWinner] = useState('')
|
||||
|
||||
Reference in New Issue
Block a user