API Reference
Programmatic methods available on the ChatEngine instance.
API Reference
Constructor
new ChatEngine(server, options?)server accepts:
- A Node.js
http.Server/https.Server/ HTTP2 server - A port number (it will create the server for you)
- An existing
socket.io.Serverinstance
Public Instance Methods
These methods are intended for server-side / admin use:
-
createRoom(options: CreateRoomOptions): Room- Programmatically creates a room on the server.
- Automatically joins active members' sockets to the room.
- See
CreateRoomOptionsin@ravex/types.
-
getRoom(roomId: string): Room | undefined -
getUser(userId: string): User | undefined- Returns the user and their current connection state.
-
kickUser(roomId: string, userId: string, reason = 'Removed from room'): void- Removes the user from the room.
- Disconnects their sockets from that room.
- Emits
room:kickedto the affected user androom:user_kickedto the room.
-
get io(): Server- Direct access to the underlying Socket.IO server instance.
-
destroy(): void- Cleans up the rate limiter and presence handler intervals.
Most client actions (joining rooms, sending messages, etc.) go through Socket events rather than these direct methods.