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-05-26 21:12:01 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1ef3174e81f4599a9ab0fea7483b4e5a4ff1441a
1ef3174e
1 parent
773e0ed4
Server 클래스 작성
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
23 deletions
server/Server.ts
server/index.ts
server/Server.ts
0 → 100644
View file @
1ef3174
import
express
from
"express"
;
import
socketIo
,
{
Server
as
IoServer
}
from
"socket.io"
;
import
{
createServer
}
from
"http"
;
import
{
SocketHandler
}
from
"./SocketHandler"
;
import
{
RoomManager
}
from
"./room/RoomManager"
;
export
class
Server
{
public
readonly
port
:
number
;
private
readonly
io
:
IoServer
;
constructor
(
port
:
number
)
{
this
.
port
=
port
;
const
app
=
express
();
const
server
=
createServer
(
app
);
this
.
io
=
new
socketIo
.
Server
(
server
);
const
handler
=
new
SocketHandler
();
const
roomManager
=
new
RoomManager
();
roomManager
.
create
(
"테스트 방 #1"
,
8
);
roomManager
.
create
(
"테스트 방 #2"
,
4
);
roomManager
.
create
(
"테스트 방 #3"
,
2
);
this
.
io
.
on
(
"connection"
,
(
socket
)
=>
{
handler
.
connected
(
socket
);
});
server
.
listen
(
port
,
()
=>
console
.
log
(
`Listening on
${
port
}
`
));
}
public
close
():
void
{
this
.
io
.
close
();
}
}
server/index.ts
View file @
1ef3174
import
express
from
"express"
;
import
socketIo
from
"socket.io"
;
import
{
createServer
}
from
"http"
;
import
{
SocketHandler
}
from
"./SocketHandler"
;
import
{
RoomManager
}
from
"./room/RoomManager"
;
import
{
Server
}
from
"./Server"
;
const
PORT
=
3000
;
const
app
=
express
();
const
server
=
createServer
(
app
);
const
io
=
new
socketIo
.
Server
(
server
);
const
handler
=
new
SocketHandler
();
const
roomManager
=
new
RoomManager
();
roomManager
.
create
(
"테스트 방 #1"
,
8
);
roomManager
.
create
(
"테스트 방 #2"
,
4
);
roomManager
.
create
(
"테스트 방 #3"
,
2
);
io
.
on
(
"connection"
,
(
socket
)
=>
{
handler
.
connected
(
socket
);
});
server
.
listen
(
PORT
,
()
=>
console
.
log
(
`Listening on
${
PORT
}
`
));
new
Server
(
3000
);
...
...
Please
register
or
login
to post a comment