Lumen.SSE
1.0.4
dotnet add package Lumen.SSE --version 1.0.4
NuGet\Install-Package Lumen.SSE -Version 1.0.4
<PackageReference Include="Lumen.SSE" Version="1.0.4" />
<PackageVersion Include="Lumen.SSE" Version="1.0.4" />
<PackageReference Include="Lumen.SSE" />
paket add Lumen.SSE --version 1.0.4
#r "nuget: Lumen.SSE, 1.0.4"
#addin nuget:?package=Lumen.SSE&version=1.0.4
#tool nuget:?package=Lumen.SSE&version=1.0.4
πLumen β SSE for ASP.NET Core
A lightweight, configurable Server-Sent Events (SSE) library for ASP.NET Core.
Easily add real-time, uni-directional server-to-client messaging without WebSockets.
β¨ Features
- β Simple integration with minimal APIs
- π§© Middleware-based connection handling
- π§ Supports multiple clients & devices per user
- π Built-in ping/keep-alive
- π§ Fully configurable endpoints and connection logic
- π¦ .NET 6/7/8 compatible
π¦ Installation
Install via NuGet:
dotnet add package Lumen.SSE
π Usage
1. Configure services
To customize global SSE behavior (ping interval, connection limits, etc.), see
π AddSse Configuration Options
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSse();
2. Configure middleware
To customize middleware-level behavior such as connection path, user/device IDs, etc., see
π UseSse Configuration Options
var app = builder.Build();
app.UseSse();
3. Send events
To send events in different ways and configure middleware part, see π Sending Events with ISsePublisher
app.MapPost("/send-message", async (
Message message,
ISsePublisher sse)
=> await sse.New()
.SetEvent("new_message")
.SetData(message)
.SendToAllClientsAsync());
π‘ Client-Side (JavaScript)
const sseUrl = `https://localhost:7287/sse/connection`;
const eventSource = new EventSource(sseUrl);
eventSource.onopen = () => {
console.log("β
Connected to SSE server");
};
eventSource.addEventListener("new_message", (event) => {
const parsedData = JSON.parse(event.data);
console.log("π¨ New Message:", parsedData);
});
eventSource.onerror = (err) => {
console.error("π¨ SSE connection error:", err);
};
π SSE vs WebSockets
Feature | SSE (Server-Sent Events) | WebSockets |
---|---|---|
Direction | Server β Client (one-way) | Bi-directional (Client β¬ Server) |
Protocol | HTTP/1.1 (works with HTTP/2 partial support) | Custom over TCP (upgrades from HTTP) |
Browser Support | Widely supported, except for IE/old Edge | Widely supported |
Complexity | Simple to implement | More complex (stateful, needs connection management) |
Reconnection | Built-in automatic reconnection | Manual reconnection logic |
Use Case | Notifications, live feeds, updates | Chat apps, multiplayer games, complex interaction |
Proxy-Friendly | Yes | Sometimes blocked by firewalls/proxies |
π’ Use SSE when:
- You only need server-to-client updates
- You want a simple, scalable, and HTTP-friendly solution
π‘ Use WebSockets when:
- You need real-time two-way communication
- The client should also be able to push events to the server
π‘ Why choose Lumen (SSE)?
- Zero dependencies
- High performance for broadcasting updates
- Great for lightweight, read-only real-time applications
π¬ Questions? Feedback?
Feel free to open an issue or contact the maintainer.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Lumen.Core (>= 1.0.4)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.Extensions.Options (>= 9.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.