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-09 21:47:15 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
72359b5c82b2e817e0512a38aa03bdd5dafe08d6
72359b5c
1 parent
383a197f
createRoom 메세지 구현
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
common/message.ts
server/user/User.ts
common/message.ts
View file @
72359b5
...
...
@@ -29,6 +29,12 @@ export class ServerInboundMessageRecordMap {
result
:
Array
(
RoomDescriptionRecord
),
});
// 방을 만듭니다.
createRoom
=
Record
({
name
:
String
,
result
:
RoomInfoRecord
,
});
// 방에 접속합니다.
joinRoom
=
Record
({
uuid
:
String
,
...
...
server/user/User.ts
View file @
72359b5
...
...
@@ -20,6 +20,16 @@ export class User {
roomList
:
(
user
,
message
)
=>
{
return
{
ok
:
true
,
result
:
connection
.
roomManager
.
list
()
};
},
createRoom
:
(
user
,
message
)
=>
{
if
(
user
.
room
)
{
return
{
ok
:
false
};
}
if
(
message
.
name
.
length
>=
30
||
message
.
name
.
trim
().
length
===
0
)
{
return
{
ok
:
false
};
}
const
room
=
connection
.
roomManager
.
create
(
message
.
name
,
8
,
user
);
return
{
ok
:
true
,
result
:
room
.
getInfo
()
};
},
joinRoom
:
(
user
,
message
)
=>
{
const
room
=
connection
.
roomManager
.
get
(
message
.
uuid
);
if
(
user
.
room
||
!
room
)
{
...
...
Please
register
or
login
to post a comment