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-01 17:48:03 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4b9d5682402175d4397a40d3b964c855d9848dc8
4b9d5682
1 parent
29115d2d
타입 정비
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
21 deletions
server/room/types.ts → common/dataType.ts
common/message.ts
server/user/types.ts
server/room/types
.ts
→
common/dataType
.ts
View file @
4b9d568
import
{
UserData
}
from
"../user/types"
;
/**
* 방 리스트에서 사용됩니다.
*/
...
...
@@ -19,3 +17,7 @@ export interface RoomInfo {
maxUsers
:
number
;
users
:
UserData
[];
}
export
interface
UserData
{
username
:
string
;
}
...
...
common/message.ts
View file @
4b9d568
import
{
RoomDescription
,
RoomInfo
}
from
"./dataType"
;
// 서버로 들어오는 메세지 타입을 정의합니다.
// 'result' 속성은 서버 요청 결과에만 포함되는 특별한 속성입니다.
export
interface
ServerInboundMessageMap
{
...
...
@@ -8,25 +10,13 @@ export interface ServerInboundMessageMap {
// 방 목록을 요청합니다.
roomList
:
{
result
:
{
uuid
:
string
;
name
:
string
;
currentUsers
:
number
;
maxUsers
:
number
;
}[];
result
:
RoomDescription
[];
};
// 방에 접속합니다.
joinRoom
:
{
uuid
:
string
;
result
:
{
uuid
:
string
;
name
:
string
;
maxUsers
:
number
;
users
:
{
username
:
string
;
}[];
};
result
:
RoomInfo
;
};
// 방에서 나갑니다.
...
...
@@ -131,8 +121,16 @@ export interface ServerOutboundMessageMap {
};
}
export
interface
ServerResponse
<
T
>
{
export
type
ServerInboundMessage
<
Key
extends
keyof
ServerInboundMessageMap
>
=
Omit
<
ServerInboundMessageMap
[
Key
],
"result"
>
;
export
interface
ServerResponse
<
Key
extends
keyof
ServerInboundMessageMap
>
{
ok
:
boolean
;
reason
?:
string
;
result
?:
T
;
result
?:
"result"
extends
keyof
ServerInboundMessageMap
[
Key
]
?
ServerInboundMessageMap
[
Key
][
"result"
]
:
never
;
}
export
type
ServerOutboundMessage
<
Key
extends
keyof
ServerOutboundMessageMap
>
=
ServerOutboundMessageMap
[
Key
];
...
...
server/user/types.ts
deleted
100644 → 0
View file @
29115d2
export
interface
UserData
{
username
:
string
;
}
Please
register
or
login
to post a comment