thelapssql3213
@thelapssql3213
Reviews Written
1
Average Rating
5.0
Posts
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.tsinterface 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
- 860
Q&A
์คํ ์ ๊ฒฐ๊ณผ์ฐฝ์์ ํ๊ธ์ด ๋ฒ์ญ์ด ์๋ผ์ ์ถ๋ ฅ๋ผ์
webSocket.send(encodeURIComponent("ํด๋ผ์ด์ธํธ์ ๋๋ค.")); ws.on("message", (server) => { console.log(decodeURIComponent(server)); });
- 0
- 2
- 528
Q&A
TypeError: RateLimit is not a constructor
6์ด๋ฉด new ์ญ์ ํ๋ฉด ๋ฉ๋๋ค! https://www.npmjs.com/package/express-rate-limit
- 1
- 2
- 794




