Jung.SimpleWebSocket
2.0.2
dotnet add package Jung.SimpleWebSocket --version 2.0.2
NuGet\Install-Package Jung.SimpleWebSocket -Version 2.0.2
<PackageReference Include="Jung.SimpleWebSocket" Version="2.0.2" />
<PackageVersion Include="Jung.SimpleWebSocket" Version="2.0.2" />
<PackageReference Include="Jung.SimpleWebSocket" />
paket add Jung.SimpleWebSocket --version 2.0.2
#r "nuget: Jung.SimpleWebSocket, 2.0.2"
#:package Jung.SimpleWebSocket@2.0.2
#addin nuget:?package=Jung.SimpleWebSocket&version=2.0.2
#tool nuget:?package=Jung.SimpleWebSocket&version=2.0.2
Jung.SimpleWebSocket
Jung.SimpleWebSocket is a lightweight and easy-to-use library for working with WebSocket connections in .NET.
It is built on top of the System.Net.WebSockets namespace and provides a simple API for creating WebSocket clients and servers.
By using a TcpListener and TcpClient, Jung.SimpleWebSocket is able to handle WebSocket connections without the need for a full-fledged HTTP server.
You also don't need admin rights to run the server.
Installation
You can install Jung.SimpleWebSocket via NuGet package manager or by manually downloading the library.
NuGet Package Manager
- Open the NuGet Package Manager Console in Visual Studio.
- Run the following command to install the package:
Install-Package Jung.SimpleWebSocket.
Manual Download
- Go to the Jung.SimpleWebSocket GitHub repository.
- Click on the "Code" button and select "Download ZIP" to download the library.
- Extract the ZIP file to a location of your choice.
- Build the solution in Visual Studio.
- Add a reference to the
Jung.SimpleWebSocket.dllfile in your project.
Usage
Using Jung.SimpleWebSocket is straightforward. Here's a simple example for the server:
// Import the Jung.SimpleWebSocket namespace
using Jung.SimpleWebSocket;
// Create a WebSocket server
var server = new SimpleWebSocketServer(System.Net.IPAddress.Any, 8010);
server.ClientConnected += (sender, e) => System.Console.WriteLine($"Client connected");
server.MessageReceived += (sender, e) => System.Console.WriteLine($"Message received: {e.Message}");
server.ClientDisconnected += (sender, e) => System.Console.WriteLine($"Client disconnected");
server.Start(CancellationToken.None);
And here's a simple example for the client:
// Import the Jung.SimpleWebSocket namespace
using Jung.SimpleWebSocket;
// Create a WebSocket client and send "Hello World!"
var client = new SimpleWebSocketClient(System.Net.IPAddress.Loopback.ToString(), 8010, "/");
client.MessageReceived += (sender, e) => Console.WriteLine(e.Message);
client.BinaryMessageReceived += (sender, e) => Console.WriteLine(e.Message);
client.Disconnected += (sender, e) => Console.WriteLine("Disconnected");
await client.ConnectAsync(CancellationToken.None);
await client.SendMessageAsync("Hello World!", CancellationToken.None);
await client.DisconnectAsync();
For more advanced usage and configuration options, please refer to the documentation.
Contributing
Contributions are welcome! If you find a bug or have a feature request, please open an issue on the Jung.SimpleWebSocket GitHub repository.
License
Jung.SimpleWebSocket is licensed under the MIT License.
| 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
- Microsoft.Extensions.Logging (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.