Skip to content

Hello NestForge WebSockets

What the WebSocket-first example includes and how it combines gateway behavior with microservice patterns.

This example shows a gateway-first application that uses NestForge’s WebSocket support while keeping provider resolution and config loading inside the framework module model.

The example currently includes:

  • src/main.rs
  • src/app_module.rs
  • src/app_config.rs
  • src/ws/mod.rs
  • src/ws/events_gateway.rs
  • src/ws/patterns.rs

Bootstraps an HTTP server and mounts a WebSocket gateway on the default /ws route. It listens on port 3002.

Registers and exports the app config plus a WsPatterns registry provider.

Defines the EventsGateway that:

  • sends an initial connection message
  • resolves AppConfig
  • optionally resolves WsPatterns
  • loops over incoming frames
  • delegates supported frames to handle_websocket_microservice_message(...)

Defines transport-neutral patterns such as:

  • app.info
  • app.ping
  • how gateways receive WebSocketContext
  • how to resolve providers from the gateway
  • how to mix direct WebSocket behavior with microservice-pattern dispatch
  • how to expose a lightweight event-driven interface without a full broker