inflearn logo
講義

講義

知識共有

thelapssql3213さんの投稿

thelapssql3213 thelapssql3213

@thelapssql3213

レビュー投稿数
1
平均評価
5.0

投稿 3

Q&A

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
閲覧数
933

Q&A

TypeError: RateLimit is not a constructor

6이면 new 삭제하면 됩니다! https://www.npmjs.com/package/express-rate-limit

いいね数
1
コメント数
2
閲覧数
819