Serinus realtime features

From francescovallone/serinus · View interactive version

Serinus realtime features is an AI agent skill from the GitHub repository francescovallone/serinus. Use when implementing Serinus real-time features with WebSockets or Server-Sent Events, including WsModule, WebSocketGateway, SseModule, SseController, and SseEmitter.

How to use this skill

Skill file

Serinus Real-Time Features

WebSocket Guidelines

SSE Guidelines

Prefer This Pattern

import 'package:serinus/serinus.dart';

class EventsGateway extends WebSocketGateway {
  EventsGateway() : super(path: '/events');

  @override
  Future<void> onMessage(dynamic data, WebSocketContext context) async {
    context.sendText('echo: $data');
  }
}

class NotificationsController extends Controller with SseController {
  NotificationsController() : super('/notifications') {
    onSse(Route.get('/stream'), (SseContext context) async* {
      yield 'connected';
    });
  }
}

class RealtimeModule extends Module {
  RealtimeModule()
      : super(
          imports: [WsModule(), SseModule()],
          controllers: [NotificationsController()],
          providers: [EventsGateway()],
        );
}

Emitting SSE Outside the SSE Route

final emitter = context.use<SseEmitter>();
emitter.send('refresh');

Avoid

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.