Jung.SimpleWebSocket 2.0.2

dotnet add package Jung.SimpleWebSocket --version 2.0.2
                    
NuGet\Install-Package Jung.SimpleWebSocket -Version 2.0.2
                    
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="Jung.SimpleWebSocket" Version="2.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Jung.SimpleWebSocket" Version="2.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Jung.SimpleWebSocket" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Jung.SimpleWebSocket --version 2.0.2
                    
#r "nuget: Jung.SimpleWebSocket, 2.0.2"
                    
#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.
#:package Jung.SimpleWebSocket@2.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Jung.SimpleWebSocket&version=2.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Jung.SimpleWebSocket&version=2.0.2
                    
Install as a Cake Tool

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

  1. Open the NuGet Package Manager Console in Visual Studio.
  2. Run the following command to install the package: Install-Package Jung.SimpleWebSocket.

Manual Download

  1. Go to the Jung.SimpleWebSocket GitHub repository.
  2. Click on the "Code" button and select "Download ZIP" to download the library.
  3. Extract the ZIP file to a location of your choice.
  4. Build the solution in Visual Studio.
  5. Add a reference to the Jung.SimpleWebSocket.dll file 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.0.2 190 3/27/2025
2.0.1 173 9/20/2024
2.0.0 165 9/19/2024
1.1.0 193 9/18/2024
1.0.0 175 9/18/2024