Ravex

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.Server instance

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 CreateRoomOptions in @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:kicked to the affected user and room:user_kicked to 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.

On this page