WebSocket · In depth

BaseSocketServer

Shared lifecycle and route-composition base for SocketServer and SecureSocketServer. Extend the concrete servers for normal applications; use this type when building infrastructure integrations.

Explain it like I’m five

The simple mental model

BaseSocketServer is the engine room beneath both plain and secure socket servers. It coordinates routes and upgrades without deciding how the outer listener was created.

When it fits

When should I use it?

Use this advanced surface for custom integrations that need Redweb routing on a specially managed Node HTTP or HTTPS server.

A practical API pattern

Follow the example

This pattern explains the named API. Application classes, credentials, and assets may need to be supplied; use a complete recipe for a runnable starting point.

Read this article as Markdown

JavaScript
import { BaseSocketServer } from 'redweb'

// SocketServer and SecureSocketServer inherit:
// addRoute(), handleUpgrade(), beginDrain(), and shutdown().
  1. 1

    Your application supplies or prepares the listener.

  2. 2

    BaseSocketServer attaches bounded WebSocket upgrade and route lifecycle behavior.

  3. 3

    Concrete server ownership remains visible, including whether Redweb may listen or close it.

Surface area

Methods and members

addRoute(RouteClass)

Creates and registers one route class while enforcing unique paths.

beginDrain()

Stops accepting new upgrades across every registered route.

shutdown()

Drains routes and closes owned listeners without closing caller-owned servers.