![]() |
VOOZH | about |
dotnet add package SimpleWebSocketServer.SIBS.Lib --version 1.0.26
NuGet\Install-Package SimpleWebSocketServer.SIBS.Lib -Version 1.0.26
<PackageReference Include="SimpleWebSocketServer.SIBS.Lib" Version="1.0.26" />
<PackageVersion Include="SimpleWebSocketServer.SIBS.Lib" Version="1.0.26" />Directory.Packages.props
<PackageReference Include="SimpleWebSocketServer.SIBS.Lib" />Project file
paket add SimpleWebSocketServer.SIBS.Lib --version 1.0.26
#r "nuget: SimpleWebSocketServer.SIBS.Lib, 1.0.26"
#:package SimpleWebSocketServer.SIBS.Lib@1.0.26
#addin nuget:?package=SimpleWebSocketServer.SIBS.Lib&version=1.0.26Install as a Cake Addin
#tool nuget:?package=SimpleWebSocketServer.SIBS.Lib&version=1.0.26Install as a Cake Tool
A simple WebSocket server implementation in C# using SimpleWebSocketServer.SIBS.Models and Newtonsoft.Json for JSON parsing.
SimpleWebSocketServer.SIBS is a lightweight WebSocket server library designed to handle various types of WebSocket messages, including terminal status responses, authentication credential requests, payment processing requests, event notifications, and error notifications.
Clone the repository:
git clone https://github.com/yourusername/SimpleWebSocketServer.SIBS.git
Navigate to the project directory:
cd SimpleWebSocketServer.SIBS
Install the required NuGet packages:
dotnet add package Newtonsoft.Json
dotnet restore
Create an instance of WebSocketServerSibs and start the server:
using SimpleWebSocketServer.SIBS;
var webSocketServer = new WebSocketServerSibs();
webSocketServer.Start("http://localhost:5000/");
Subscribe to the events to handle incoming messages and client connections:
webSocketServer.ClientConnected += (sender, e) =>
{
Console.WriteLine("Client connected.");
};
webSocketServer.TerminalStatusReqResponseReceived += (sender, response) =>
{
Console.WriteLine("Received Terminal Status Response.");
};
webSocketServer.SetAuthCredentialsReqReceived += (sender, response) =>
{
Console.WriteLine("Received Set Auth Credentials Response.");
};
webSocketServer.ProcessPaymentReqReceived += (sender, response) =>
{
Console.WriteLine("Received Process Payment Response.");
};
webSocketServer.EventNotificationReceived += (sender, response) =>
{
Console.WriteLine("Received Event Notification.");
};
webSocketServer.ErrorNotificationReceived += (sender, response) =>
{
Console.WriteLine("Received Error Notification.");
};
Send a message to the client:
await webSocketServer.SendMessageToClient("Hello, client!");
The following events are available for handling:
ClientConnectedTerminalStatusReqResponseReceivedSetAuthCredentialsReqReceivedProcessPaymentReqReceivedEventNotificationReceivedErrorNotificationReceivedHere's a complete example to demonstrate how to start the server and handle events:
using System;
using SimpleWebSocketServer.SIBS;
namespace WebSocketServerExample
{
class Program
{
static async Task Main(string[] args)
{
var webSocketServer = new WebSocketServerSibs();
webSocketServer.Start("http://localhost:5000/");
webSocketServer.ClientConnected += (sender, e) =>
{
Console.WriteLine("Client connected.");
};
webSocketServer.TerminalStatusReqResponseReceived += (sender, response) =>
{
Console.WriteLine("Received Terminal Status Response.");
};
webSocketServer.SetAuthCredentialsReqReceived += (sender, response) =>
{
Console.WriteLine("Received Set Auth Credentials Response.");
};
webSocketServer.ProcessPaymentReqReceived += (sender, response) =>
{
Console.WriteLine("Received Process Payment Response.");
};
webSocketServer.EventNotificationReceived += (sender, response) =>
{
Console.WriteLine("Received Event Notification.");
};
webSocketServer.ErrorNotificationReceived += (sender, response) =>
{
Console.WriteLine("Received Error Notification.");
};
// Send a message to the client
await webSocketServer.SendMessageToClient("Hello, client!");
}
}
}
This project is licensed under the MIT License - see the file for details.
Contributions are welcome! Please feel free to submit pull requests or open issues for bug fixes, improvements, or new features.
For support, questions, or suggestions, please open an issue.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net472 net472 is compatible. net48 net48 was computed. net481 net481 was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.26 | 223 | 12/9/2024 |
| 1.0.25 | 176 | 12/9/2024 |
| 1.0.24 | 199 | 12/3/2024 |
| 1.0.23 | 192 | 11/27/2024 |
| 1.0.21 | 187 | 10/28/2024 |
| 1.0.20 | 203 | 10/11/2024 |
| 1.0.19 | 181 | 10/7/2024 |
| 1.0.18 | 183 | 10/7/2024 |
| 1.0.17 | 179 | 10/7/2024 |
| 1.0.16 | 191 | 10/4/2024 |
| 1.0.15 | 178 | 10/1/2024 |
| 1.0.14 | 185 | 10/1/2024 |
| 1.0.13 | 186 | 10/1/2024 |
| 1.0.12 | 188 | 9/30/2024 |
| 1.0.11 | 183 | 9/26/2024 |
| 1.0.10 | 180 | 9/25/2024 |
| 1.0.9 | 200 | 9/6/2024 |
| 1.0.8 | 196 | 9/5/2024 |
| 1.0.7 | 262 | 9/5/2024 |
| 1.0.6 | 203 | 7/30/2024 |