From 5f7ba73f128eddb5c3e4e11dd0025aa1c8d2f385 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Thu, 18 Feb 2021 11:43:05 +0100 Subject: more progress? (broken) --- pages/game.tsx | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'pages') diff --git a/pages/game.tsx b/pages/game.tsx index 1c66f92..8728674 100644 --- a/pages/game.tsx +++ b/pages/game.tsx @@ -1,17 +1,10 @@ import { CSSProperties, Component } from 'react'; -import { io } from 'socket.io-client'; +import { io as socket } from 'socket.io-client'; import axios from 'axios'; import { userInfo } from '../api/api'; import * as cookies from 'react-cookies'; -var socket = io("http://localhost:2080/api/game/socket/"); - -socket.on("connect", () => { - console.log("connect") -}) -socket.on("disconnect", () => { - console.log("disconnect") -}) +var io = socket("http://localhost:2080/api/game/socket/"); import { NavBar } from '../components/navbar'; import { CenteredPage } from '../components/page'; @@ -57,6 +50,14 @@ interface VoerGameProps { class VoerGame extends Component { constructor(props: VoerGameProps) { super(props); + + io.on("connect", () => { + console.log("connect") + io.emit("resign", {"cool": "data"}); + }) + io.on("disconnect", () => { + console.log("disconnect") + }) } width = 7; @@ -87,7 +88,7 @@ class VoerGame extends Component { token: cookies.load("token"), gameID: "fortnite" }) - socket.emit("new_move", { + io.emit("new_move", { move: column, token: cookies.load("token"), gameID: "fortnite" -- cgit v1.2.3