Skip to content
Snippets Groups Projects
Commit d978ec7b authored by Joni Laukka's avatar Joni Laukka
Browse files

Socket now sends data instead of type

parent 9ad5424a
No related branches found
No related tags found
2 merge requests!46Development to testing,!41Notifications + small updates
This commit is part of merge request !41. Comments created here will be created in the context of that merge request.
...@@ -98,7 +98,7 @@ export default class GameView extends React.Component { ...@@ -98,7 +98,7 @@ export default class GameView extends React.Component {
getSocketSignal = data => { getSocketSignal = data => {
this.setState( this.setState(
{ {
socketSignal: data // TODO: change to data socketSignal: data
}, },
() => { () => {
this.setState({ this.setState({
...@@ -197,7 +197,11 @@ export default class GameView extends React.Component { ...@@ -197,7 +197,11 @@ export default class GameView extends React.Component {
zoom={this.state.zoom} zoom={this.state.zoom}
mapUrl={this.state.mapUrl} mapUrl={this.state.mapUrl}
currentGameId={this.state.gameInfo.id} currentGameId={this.state.gameInfo.id}
socketSignal={this.state.socketSignal} socketSignal={
this.state.socketSignal === null
? null
: this.state.socketSignal.type
}
role={this.state.role} role={this.state.role}
> >
<NotificationPopup socketSignal={this.state.socketSignal} /> <NotificationPopup socketSignal={this.state.socketSignal} />
......
...@@ -20,8 +20,8 @@ export default class ClientSocket extends React.Component { ...@@ -20,8 +20,8 @@ export default class ClientSocket extends React.Component {
console.log("hi socket"); console.log("hi socket");
// need to explicitly update drawings and trackings when gameID first becomes available // need to explicitly update drawings and trackings when gameID first becomes available
if (this.props.gameId !== null) { if (this.props.gameId !== null) {
await this.props.getSocketSignal("drawing-update"); await this.props.getSocketSignal({ type: "drawing-update" });
await this.props.getSocketSignal("tracking-update"); await this.props.getSocketSignal({ type: "tracking-update" });
} }
this.initSocket(); this.initSocket();
} }
...@@ -47,8 +47,7 @@ export default class ClientSocket extends React.Component { ...@@ -47,8 +47,7 @@ export default class ClientSocket extends React.Component {
// set the socket to listen gameId-thread // set the socket to listen gameId-thread
socket.on(this.props.gameId, data => { socket.on(this.props.gameId, data => {
console.log(data.type); this.props.getSocketSignal(data);
this.props.getSocketSignal(data.type);
// check socket update type // check socket update type
this.setState({ update: data }); this.setState({ update: data });
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment