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 22:46:49 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
d9424f2e2154f8f0f3cfd83d72b39076e9e07f63
d9424f2e
2 parents
9e57e5d3
0c6c9054
Builds for 1 pipeline
passed
in 7 minutes 59 seconds
Merge branch 'bugfix/login-missing-uuid' into develop
Changes
2
Builds
3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
4 deletions
server/connection/Connection.ts
server/test/login.test.ts
server/connection/Connection.ts
View file @
d9424f2
...
...
@@ -77,14 +77,17 @@ export class Connection {
private
handleLogin
(
message
:
ServerInboundMessage
<
"login"
>
):
ServerResponse
<
"login"
>
{
if
(
message
.
nickname
.
length
>
12
||
message
.
nickname
.
trim
().
length
===
0
)
{
return
{
ok
:
false
};
if
(
message
.
nickname
.
length
>
12
)
{
return
{
ok
:
false
,
reason
:
"닉네임은 최대 12글자입니다."
};
}
if
(
message
.
nickname
.
trim
().
length
===
0
)
{
return
{
ok
:
false
,
reason
:
"닉네임을 공백으로 설정할 수 없습니다."
};
}
this
.
user
=
new
User
(
message
.
nickname
,
this
);
// console.log(`User ${message.username} has logged in!`);
return
{
ok
:
true
};
return
{
ok
:
true
,
result
:
this
.
user
.
username
};
}
public
handleDisconnect
():
void
{
...
...
server/test/login.test.ts
View file @
d9424f2
...
...
@@ -6,7 +6,8 @@ describe("로그인", () => {
it
(
"닉네임으로 로그인합니다"
,
()
=>
{
const
roomManager
=
new
RoomManager
();
const
socket
=
new
SocketTester
(
roomManager
);
socket
.
testOk
(
"login"
,
{
nickname
:
"guest"
});
const
response
=
socket
.
test
(
"login"
,
{
nickname
:
"guest"
});
expect
(
response
.
result
!==
undefined
).
eq
(
true
);
expect
(
socket
.
connection
.
user
?.
nickname
).
eq
(
"guest"
);
});
it
(
"빈 닉네임으로 로그인할 수 없습니다"
,
()
=>
{
...
...
Please
register
or
login
to post a comment