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
Overnap
2021-06-09 22:44:07 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a2963379198d2e66e142c8741f1bd3d78b87b706
a2963379
1 parent
9f836480
createRooms 프로토콜에 맞게 수정
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
web/src/components/rooms/Create.tsx
web/src/components/rooms/Create.tsx
View file @
a296337
import React, { useCallback, useContext, useState } from 'react';
import { useHistory, useLocation } from 'react-router-dom';
import SocketContext from '../../contexts/SocketContext';
import { MessageResponse, MessageType, RawMessage } from '../common/types';
import { RoomData } from '../room/types';
import { Room } from './types';
interface CreateLocation {
state: { username: string }
}
export const Create: React.FC = () => {
const history = useHistory();
const socket = useContext(SocketContext);
const [ roomName, setRoomName ] = useState('');
const location: CreateLocation = useLocation();
const createRooms = useCallback(() => {
const rawMessage: RawMessage = {
type: MessageType.ROOM_LIST_CREATE,
message: { name: roomName }
}
socket.emit('msg', rawMessage, (response: MessageResponse<Room
[]
>) => {
socket.emit('msg', rawMessage, (response: MessageResponse<Room
Data
>) => {
if (response.ok) {
// HOW?
history.push({
pathname: '/' + response.result!.uuid,
state: {
username: location.state.username,
roomData: response.result!
}
});
} else {
console.log('방 생성 오류');
}
});
}, [roomName]);
...
...
Please
register
or
login
to post a comment