Skip to content

Commit c884add

Browse files
committed
Update server
1 parent 34acbb8 commit c884add

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

server.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@ app.get('/', function(req, res) {
2424
* io.sockets.manager.rooms - 현재 생성되어 있는 모든 room 목록을 리턴
2525
*
2626
* [Send methods]
27-
* io.emit('message', data); // 자신 포함 전체룸 유저들에게 전송
28-
* io.sockets.in(roomId).emit('message', data); // 자신 포함 해당룸에 유저들에게 전송
29-
* socket.broadcast.emit('message', data); // 자신 제외 메시지 전송
27+
* io.emit('message', data); // 자신 포함 전체룸 유저들에게 전송
28+
* io.sockets.in(roomId).emit('message', data); // 자신 포함 해당룸 유저들에게 전송
29+
* socket.broadcast.emit('message', data); // 자신 제외 전체에 메시지 전송
30+
* socket.broadcast.to(roomId).emit('message', data); // 자신 제외 해당룸 유저들에게 전송
3031
*/
3132
var socketIds = [];
3233
io.on('connection', function(socket) {
34+
35+
// 소켓 연결해제
36+
socket.on('disconnect', function() {
37+
console.log('a user disconnected', socket
38+
.id);
39+
});
40+
3341
var roomId = null;
3442

3543
// 룸접속
@@ -71,10 +79,7 @@ io.on('connection', function(socket) {
7179
socket.broadcast.to(roomId).emit('typing', nickName);
7280
});
7381

74-
// 소켓 연결해제
75-
socket.on('disconnect', function() {
76-
console.log('a user disconnected');
77-
});
82+
7883
});
7984

8085
// server listen start

0 commit comments

Comments
 (0)