Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이정민
/
OPproject
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
서예진
2019-12-03 19:30:53 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2c7996ac5942fceb56026fa43dd5ff26f4a7e54c
2c7996ac
1 parent
e4a0995b
socket.js, sse,js
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
socket.js
sse.js
socket.js
0 → 100644
View file @
2c7996a
const
SocketIO
=
require
(
'socket.io'
);
module
.
exports
=
(
server
,
app
)
=>
{
const
io
=
SocketIO
(
server
,
{
path
:
'/socket.io'
});
app
.
set
(
'io'
,
io
);
io
.
on
(
'connection'
,
(
socket
)
=>
{
const
req
=
socket
.
request
;
const
{
headers
:
{
referer
}
}
=
req
;
const
roomId
=
referer
.
split
(
'/'
)[
referer
.
split
(
'/'
).
length
-
1
];
socket
.
join
(
roomId
);
socket
.
on
(
'disconnect'
,
()
=>
{
socket
.
leave
(
roomId
);
});
});
};
sse.js
0 → 100644
View file @
2c7996a
const
SSE
=
require
(
'sse'
);
module
.
exports
=
(
server
)
=>
{
const
sse
=
new
SSE
(
server
);
sse
.
on
(
'connection'
,
(
client
)
=>
{
setInterval
(()
=>
{
client
.
send
(
Date
.
now
().
toString
());
},
1000
);
});
};
Please
register
or
login
to post a comment