Merge linter changes into branch
parent
0fc8a7383f
commit
4b22c5ead8
|
|
@ -142,6 +142,7 @@ dist
|
|||
|
||||
# production
|
||||
/build
|
||||
*/build/
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import {
|
|||
WebSocketGateway,
|
||||
} from '@nestjs/websockets';
|
||||
import { PlayerService } from './players/player.service';
|
||||
import { Socket } from 'socket.io'
|
||||
import { Socket } from 'socket.io';
|
||||
|
||||
@WebSocketGateway({ cors: true })
|
||||
@Injectable()
|
||||
|
|
@ -20,7 +20,10 @@ export class AppService implements OnGatewayConnection {
|
|||
}
|
||||
|
||||
@SubscribeMessage('example-request')
|
||||
handleCustomEvent(@ConnectedSocket() client:Socket,@MessageBody() data: string): unknown {
|
||||
handleCustomEvent(
|
||||
@ConnectedSocket() client: Socket,
|
||||
@MessageBody() data: string,
|
||||
): unknown {
|
||||
this.logger.debug(`Received request in backend with data: ${data}`);
|
||||
this.logger.debug(`Received data id from client: ${client.id}`);
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { MessageBody, OnGatewayConnection, SubscribeMessage, WebSocketGateway } from '@nestjs/websockets';
|
||||
|
||||
@Injectable()
|
||||
export class PlayerService {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export enum ClientEvent {
|
||||
CREATE_LOBBY = "create-lobby",
|
||||
JOIN_LOBBY = "join-lobby",
|
||||
START_GAME = "start-game"
|
||||
START_GAME = "start-game",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
export type CreateLobbyEvent = {
|
||||
userName: string;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export type JoinLobbyEvent = {
|
||||
userName: string;
|
||||
lobbyId: string;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export enum ServerError {
|
||||
CREATE_LOBBY_ERROR = "create-lobby-error",
|
||||
JOIN_LOBBY_ERROR = "join-lobby-error"
|
||||
JOIN_LOBBY_ERROR = "join-lobby-error",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export enum ServerEvent {
|
||||
LOBBY_UPDATE = "lobby-update",
|
||||
START_ROUND = "start-round"
|
||||
START_ROUND = "start-round",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@ module.exports = {
|
|||
node: true,
|
||||
jest: true,
|
||||
},
|
||||
ignorePatterns: [".eslintrc.js", "dist/"],
|
||||
ignorePatterns: [".eslintrc.js", "dist/", "node_modules/", "build/"],
|
||||
rules: {},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
import React from "react";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import App from "./App";
|
||||
|
||||
test("Renders hello world", () => {
|
||||
render(<App />);
|
||||
expect(screen.getByText("Hello World! Front")).toBeInTheDocument();
|
||||
});
|
||||
|
|
@ -1,14 +1,9 @@
|
|||
import React from "react";
|
||||
import { io } from "socket.io-client";
|
||||
import LandingPage from './pages/landing/LandingPage';
|
||||
import LandingPage from "./pages/landing/LandingPage";
|
||||
|
||||
function App() {
|
||||
const socket = io("http://localhost:3010");
|
||||
const emitData = () =>
|
||||
console.log(socket.emit("example-request", "custom-request"));
|
||||
socket.on("example-response", (data) =>
|
||||
console.log(`Received response in front end with data: ${data}`),
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="App">
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
import React from "react"
|
||||
import React, { ChangeEvent } from "react";
|
||||
import { Socket } from "socket.io-client";
|
||||
|
||||
const LandingPage = (props: { socket: Socket }) => {
|
||||
var username = "";
|
||||
const registerUsername = (event:any) => username = event.target.value;
|
||||
let username = "";
|
||||
const registerUsername = (event: ChangeEvent<HTMLInputElement>) =>
|
||||
(username = event.target.value);
|
||||
const socket = props.socket;
|
||||
const handleCreateLobby = () => socket.emit("create-lobby", {username:username});
|
||||
return <React.Fragment>
|
||||
const handleCreateLobby = () =>
|
||||
socket.emit("create-lobby", { username: username });
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div className="LandingPageTitle">
|
||||
<h1>Trains And Roads</h1>
|
||||
</div>
|
||||
|
|
@ -21,5 +24,6 @@ const LandingPage = (props:{socket:Socket})=>{
|
|||
<button className="JoinLobbyButton secondary">Join Lobby</button>
|
||||
</div>
|
||||
</React.Fragment>
|
||||
);
|
||||
};
|
||||
export default LandingPage;
|
||||
Loading…
Reference in New Issue