diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-02-18 11:43:05 +0100 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-02-18 11:43:05 +0100 |
commit | 5f7ba73f128eddb5c3e4e11dd0025aa1c8d2f385 (patch) | |
tree | dd47fb691999da383514c7cbbe484bd2470db88b /pages | |
parent | 27c1340dbbf18638f680be8557a531180abfd53a (diff) |
more progress? (broken)
Diffstat (limited to 'pages')
-rw-r--r-- | pages/game.tsx | 21 |
1 files changed, 11 insertions, 10 deletions
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<VoerGameProps> { 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<VoerGameProps> { token: cookies.load("token"), gameID: "fortnite" }) - socket.emit("new_move", { + io.emit("new_move", { move: column, token: cookies.load("token"), gameID: "fortnite" |