Toggle navigation
Toggle navigation
This project
Loading...
Sign in
강동현
/
nodejs-game
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
강동현
2021-06-08 15:33:33 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
e6aa646c6f1812b80c4b907dea49826b0ae4f939
e6aa646c
2 parents
120063f0
e808c4d4
Merge branch 'develop' of
http://khuhub.khu.ac.kr/2020105578/nodejs-game
into develop
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
5 deletions
server/Server.ts
web/src/pages/Login.tsx
web/src/pages/Rooms.tsx
server/Server.ts
View file @
e6aa646
...
...
@@ -14,7 +14,11 @@ export class Server {
const
app
=
express
();
const
server
=
createServer
(
app
);
this
.
io
=
new
socketIo
.
Server
(
server
);
this
.
io
=
new
socketIo
.
Server
(
server
,
{
cors
:
{
origin
:
'*'
}
});
const
roomManager
=
new
RoomManager
();
...
...
web/src/pages/Login.tsx
View file @
e6aa646
...
...
@@ -21,7 +21,7 @@ export const Login: React.FC = () => {
console.error('login error!'); // TODO: 팝업 에러?
}
});
}, []);
}, [
username
]);
return (
<Main>
...
...
web/src/pages/Rooms.tsx
View file @
e6aa646
import React, { useCallback, useContext, useEffect, useState } from 'react';
import { useHistory } from 'react-router';
import { Main } from '../components/common/Main';
import { MessageResponse, MessageType, RawMessage } from '../components/common/types';
import { RoomBlock } from '../components/rooms/RoomBlock';
...
...
@@ -6,6 +7,7 @@ import { Room } from '../components/rooms/types';
import SocketContext from '../contexts/SocketContext';
export const Rooms: React.FC = () => {
const history = useHistory();
const socket = useContext(SocketContext);
const [ rooms, setRooms ] = useState<Room[]>([]);
...
...
@@ -18,9 +20,8 @@ export const Rooms: React.FC = () => {
if (response.ok) {
setRooms(response.result!);
} else {
// TODO: 에러 핸들링
console.log("방 목록을 수신하지 못함");
console.log(response);
// 로그인하지 않고 방 목록으로 왔다고 판단
history.push('/');
}
});
}, []);
...
...
Please
register
or
login
to post a comment