소개
게시글
질문&답변
2023.01.16
socket.js 에서 referer로부터 roomId를 가져올 때
저도 질문자님처럼 request.referer가 undefined 뜨더라구요. 그래서 다음과 같이 작성하였어요. index.html 클라이언트에서 "roomId"를 Socket 연결 시 Url QueryString으로 전달 const socket = io.connect( `http://localhost:2000/chat?roomId=${$roomId}`, { path: "/socket.io", transports: ["websocket"], }, ); socket.ts interface IRequestQuery { roomId: string; } socket.on("disconnect", async () => { const { roomId }: IRequestQuery = socket.handshake .query as unknown as IRequestQuery; const currentRoom = chat.adapter.rooms.get(roomId); const userCount = currentRoom?.size; console.log(userCount); });
- 0
- 3
- 506
고민있어요
2022.05.21 10:38
느낌표살인마네
- 1
- 1
- 143
스터디
모집중
2022.04.28 22:22
Node.js 온라인 스터디
- 0
- 0
- 204
고민있어요
2022.04.16 16:11
대세는 Promise.allSettled
- 0
- 1
- 114
질문&답변
2022.03.28
실행 시 결과창에서 한글이 번역이 안돼서 출력돼요
webSocket . send ( encodeURIComponent ( "클라이언트입니다." )); ws . on ( "message" , (server) => { console . log ( decodeURIComponent (server ) ); });
- 0
- 2
- 276