Fix TypeScript: add @types/ws and RawData type for WebSocket message
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { FastifyPluginAsync } from 'fastify'
|
||||
import fastifyWebsocket from '@fastify/websocket'
|
||||
import type { WebSocket } from 'ws'
|
||||
import type { WebSocket, RawData } from 'ws'
|
||||
|
||||
// hotel slug → set of connected clients
|
||||
const hotelRooms = new Map<string, Set<WebSocket>>()
|
||||
@@ -18,7 +18,7 @@ const ws: FastifyPluginAsync = async (fastify) => {
|
||||
if (!hotelRooms.has(hotel)) hotelRooms.set(hotel, new Set())
|
||||
hotelRooms.get(hotel)!.add(socket)
|
||||
|
||||
socket.on('message', (raw) => {
|
||||
socket.on('message', (raw: RawData) => {
|
||||
const data = raw.toString()
|
||||
const peers = hotelRooms.get(hotel)
|
||||
if (!peers) return
|
||||
|
||||
Reference in New Issue
Block a user