강동현

Merge branch 'develop' of http://khuhub.khu.ac.kr/2020105578/nodejs-game into develop

......@@ -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();
......
......@@ -21,7 +21,7 @@ export const Login: React.FC = () => {
console.error('login error!'); // TODO: 팝업 에러?
}
});
}, []);
}, [username]);
return (
<Main>
......
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('/');
}
});
}, []);
......