Samhammer.SocketServer.Server
8.0.0
See the version list below for details.
dotnet add package Samhammer.SocketServer.Server --version 8.0.0
NuGet\Install-Package Samhammer.SocketServer.Server -Version 8.0.0
<PackageReference Include="Samhammer.SocketServer.Server" Version="8.0.0" />
<PackageVersion Include="Samhammer.SocketServer.Server" Version="8.0.0" />
<PackageReference Include="Samhammer.SocketServer.Server" />
paket add Samhammer.SocketServer.Server --version 8.0.0
#r "nuget: Samhammer.SocketServer.Server, 8.0.0"
#:package Samhammer.SocketServer.Server@8.0.0
#addin nuget:?package=Samhammer.SocketServer.Server&version=8.0.0
#tool nuget:?package=Samhammer.SocketServer.Server&version=8.0.0
Samhammer.SocketServer
Note: The implementation is currently uni directional and only ment for communication from the server to the client.
Note2: This repo is private for multiple reasons, even though the server project would be reusable:
- To not disclose infrastructure information over the appsettings of the api
- Beacuse the api docker image is in our private docker registry
Samhammer.SocketServer.Server
A library to integrate websocket technology into an existing api project.
What can it do:
- Provide endpoint of a socket server
- Establish and keep open connections
- Send messages from the server to one or multiple clients
- Handles clientId stuff (first message sent to the client is the clientId)
How to use
Install the nuge package "Samhammer.SocketServer.Server".
Adjust jour Program.cs like that:
builder.Services.AddSocketServer(builder.Configuration); // There are overloads for different scenarios
var app = builder.Build();
app.MapSocketServer("/ws"); // Endpoint under which the socket server runs
If you use "AddSocketServer(builder.Configuration)" add this config block to appsettings:
"SocketServerOptions": {
"HeartbeatIntervalSeconds": 300,
"MaxBufferSizeInKb": 500
},
- HeartbeatIntervalSeconds: Configure how often keep alive messages should be transfered
- MaxBufferSizeInKb: Max message lengt. Everything langer will be cut off
Inject IWebsocketService to use the server:
- Task<bool> SendText(string clientId, string text) ⇒ Send a message to a specific client (returns true in case of success)
- Task BroadcastText(string text) ⇒ Send a message to all connected clients
- List<string> GetActiveClients() ⇒ Get a list of active client ids
Samhammer.SocketServer.Api
This is an entire api project that uses Samhammer.SocketServer.Server to provide endpoints for it's functionality.
How to use
Take a look at appsettings because there are a few settings that need to be overwritten via env vars. (at least the Elastic index and both AuthOptions blocks)
Docker images are pushed to registry.samhammer.oncloudandheat.com. See project "samhammer-socket-server" there.
The following API endpoints are provided:
- /ws ⇒ Websocket endpoint
- GET api/client ⇒ Get all active client ids
- POST api/notification/<clientid> ⇒ Send a message to a specific client
- POST api/notification/broadcast ⇒ Send a message to all clients
Samhammer.SocketServer.ApiClient
Contains the HTTP-Calls to access the "Samhammer.SocketServer.Api" project.
Install the nuget package "Samhammer.SocketServer.ApiClient".
Then you can Inject "ISocketServerApiClient". (it is registered in ioc by Samhammer.DependencyInjection)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.0 | 116 | 1/19/2026 |
| 10.0.0-beta.1 | 75 | 1/16/2026 |
| 8.2.5 | 107 | 1/19/2026 |
| 8.2.4 | 118 | 1/19/2026 |
| 8.2.2 | 108 | 1/19/2026 |
| 8.2.0 | 125 | 1/16/2026 |
| 8.1.0 | 197 | 7/18/2025 |
| 8.0.9 | 224 | 7/17/2025 |
| 8.0.8 | 275 | 5/12/2025 |
| 8.0.7 | 219 | 3/13/2025 |
| 8.0.6 | 183 | 2/24/2025 |
| 8.0.5 | 176 | 2/24/2025 |
| 8.0.4 | 186 | 12/4/2024 |
| 8.0.3 | 191 | 10/25/2024 |
| 8.0.2 | 197 | 6/10/2024 |
| 8.0.1 | 192 | 5/31/2024 |
| 8.0.0 | 196 | 5/31/2024 |