BaseSocketServer
Documentation for Redweb 0.13.0. Install that exact version when following these examples.
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
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 should I use it?
Use this advanced surface for custom integrations that need Redweb routing on a specially managed Node HTTP or HTTPS server.
Follow the example
This API pattern illustrates the named surface; it may require application-owned classes, credentials, or assets. Start from a complete recipe for a runnable application.
import { BaseSocketServer } from 'redweb'
// SocketServer and SecureSocketServer inherit:
// addRoute(), handleUpgrade(), beginDrain(), and shutdown().- Your application supplies or prepares the listener.
- BaseSocketServer attaches bounded WebSocket upgrade and route lifecycle behavior.
- Concrete server ownership remains visible, including whether Redweb may listen or close it.
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.
What should I watch for?
Most applications should use SocketServer or SecureSocketServer. Reach for the base class only when listener ownership cannot be expressed by their options.