nodejs-book
nodejs-book copied to clipboard
socket.io@4
개정판은 @2 사용합니다. 541쪽 $ npm i socket.io@2 597쪽 $ npm i sse socket.io@2
@4에서는 이렇게 const wrap = middleware => (socket, next) => middleware(socket.request, {}, next); chat.use(wrap(cookieParser(process.env.COOKIE_SECRET))); chat.use(wrap(sessionMiddleware));
const currentRoom = io.of('/chat').adapter.rooms.get(req.params.id); const userCount = currentRoom ? currentRoom.size : 0; if (room.max <= userCount) {