Antelcat.AspNetCore.WebSocket 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Antelcat.AspNetCore.WebSocket --version 0.1.0                
NuGet\Install-Package Antelcat.AspNetCore.WebSocket -Version 0.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Antelcat.AspNetCore.WebSocket" Version="0.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Antelcat.AspNetCore.WebSocket --version 0.1.0                
#r "nuget: Antelcat.AspNetCore.WebSocket, 0.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Antelcat.AspNetCore.WebSocket as a Cake Addin
#addin nuget:?package=Antelcat.AspNetCore.WebSocket&version=0.1.0

// Install Antelcat.AspNetCore.WebSocket as a Cake Tool
#tool nuget:?package=Antelcat.AspNetCore.WebSocket&version=0.1.0                

WebSocket

.NET wrap for WebSocket

Example

in Program.cs

var builder = WebApplication.CreateBuilder(args);

...
builder.Services.AddWebSockets();
...
    
var app = builder.Build();
...
// remember to call UseWebSockets() before MapWebSocket()
app.UseWebSockets(); 
app.MapWebSocket<SampleWebSocketClient>("/WebSocket");
...

for SampleWebSocketClient

which lifetime is Transient or Scoped, each WebSocket connection will create corresponding instance

// define your client model to receive message from WebSocket client 
public class SampleWebSocketClient : Antelcat.AspNetCore.Client
{
    protected override async Task OnConnectedAsync()
    {
        Console.WriteLine($"{Context.ConnectionId} connected");
    }

    protected override async Task OnDisconnectedAsync(Exception? exception)
    {
        Console.WriteLine($"{Context.ConnectionId} disconnected due to {exception}");
    }

    protected override async Task OnReceivedTextAsync(string text, CancellationToken token)
    {
        await this.SendAsync(text, token);
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Antelcat.AspNetCore.WebSocket:

Package Downloads
Antelcat.AspNetCore.ProtooSharp

ported to .NET from https://github.com/versatica/protoo

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.3 66 11/7/2024
0.1.2 176 10/23/2024
0.1.1 76 10/22/2024
0.1.0 95 10/9/2024

Initial