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-05-31 00:23:28 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
052635a7dffc2cc8fb1e54df667aa6cb8789f27b
052635a7
1 parent
2aa24f6c
메세지 인터페이스 추가
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
web/src/Login.tsx
web/src/Message.ts
web/src/Login.tsx
View file @
052635a
import React, { useContext, useState } from 'react';
import { RouteComponentProps } from 'react-router';
import { Footer } from './Footer';
import { MessageResponse } from './Message';
import SocketContext from './SocketContext';
export const Login: React.FC<RouteComponentProps> = ({ history }) => {
...
...
@@ -8,8 +9,8 @@ export const Login: React.FC<RouteComponentProps> = ({ history }) => {
const [ username, setUsername ] = useState("");
const login = () => {
socket.emit('login', username, (
{ ok } : { ok: boolean }
) => {
if (ok) {
socket.emit('login', username, (
response : MessageResponse<null>
) => {
if (
response.
ok) {
history.push('/rooms');
} else {
console.error('login error!'); // TODO: 팝업 에러?
...
...
web/src/Message.ts
0 → 100644
View file @
052635a
export
interface
MessageResponse
<
T
>
{
ok
:
boolean
;
reason
?:
string
;
result
?:
T
;
}
export
class
MessageType
{
static
readonly
LOGIN
=
"login"
;
static
readonly
ROOM_LIST_REQUEST
=
"room_list_request"
;
static
readonly
ROOM_JOIN
=
"room_join"
;
static
readonly
ROOM_LEAVE
=
"room_leave"
;
static
readonly
ROOM_USER_UPDATE
=
"room_user_update"
;
static
readonly
ROOM_CHAT
=
"room_chat"
;
}
Please
register
or
login
to post a comment