Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/websocket/core/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ import { RoomManager } from '../rooms';
import { BroadcastOperator } from './broadcast-operator';

/**
* Socket wrapper that provides a Socket.IO-like API over native uWebSockets.js
* This class wraps the native uWS.WebSocket and adds convenient methods
* Socket wrapper that provides a Socket.IO-like API over native uWebSockets.js.
* This class wraps the native uWS.WebSocket and adds convenient methods.
*
* IMPORTANT: `data` is initialized as an empty object cast to `TData`. The cast
* is safe for object types without required fields (the common case) but is
* unsafe when `TData` is a primitive type or has required properties: reading
* `socket.data` before assigning to it will surface a partially-typed value.
* Always assign `socket.data` before reading it in those cases.
*
* @template TData - Type of custom data attached to the socket
* @template TEmitData - Type of data that can be emitted
*/
Expand Down
Loading