WSClientGWrapper 1.0.0
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package WSClientGWrapper --version 1.0.0
NuGet\Install-Package WSClientGWrapper -Version 1.0.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="WSClientGWrapper" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WSClientGWrapper" Version="1.0.0" />
<PackageReference Include="WSClientGWrapper" />
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 WSClientGWrapper --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: WSClientGWrapper, 1.0.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.
#:package WSClientGWrapper@1.0.0
#: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=WSClientGWrapper&version=1.0.0
#tool nuget:?package=WSClientGWrapper&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
WebSocket Client Generic Wrapper (WSClientGWrapper)
Implementation of a generic wrapper for the Microsoft ClientWebSocket class (.NET Core)
How to use it?
- The class
WSClientGWrapper<TSend, TResponse>is the main definition of the generic wrapper, where theTSendis the type of data to be sended, and theTResponseis the type of the data that will be received. - To use the
stringtype to send/receive data, you can use theSimpleWebSocketClientWrapperclass.
Steps :
- Instantiate a new wrapper object by choosing one of the two options mentioned above.
e.g.
**P.S 😗*var wrapper = new WSClientGWrapper<string, string>("wss://api.com/customers");The 2nd argument in the constructor
fixRemoteCertValidationby defaultfalse, is used to enable/disable remote certificate validation.- For WebSocket secure connection
wss://we need to validate certificate, but in some cases we're gone be using self-signed certificate, and it gaves errors on connecting the WebSocket (validation errors), to skip validation set the 2nd parameter value totrue.
- For WebSocket secure connection
[Optional] Now we have our wrapper object we need to set the response converter callback :
- What is this callback ?
- This callback is used to convert the response data from
byte[]toTResponse, but we need to define how the data will be converted, by default the data is converted tostringdata type by using :Convert.ChangeType(Encoding.UTF8.GetString(bytesData), ...);
- This callback is used to convert the response data from
- What is this callback ?
- Now we need to define all needed callbacks :
OnConnect:- To be called on the WebSocket connection.
- Generally here where you need to add initialization calls (wrapper.SendMessage(...)).
- returns the current wrapper.
OnDisconnect:- To be called on the WebSocket disconnection.
- returns the current wrapper.
OnMessage:- To be called on message arrival.
- Receives in argument the
WSClientGWrapperArgs:- This class contains :
Data: the message payload.Endpoint: the current URI where the WebSocket is connected to it.\Wrapper: is the current wrapper object.
- This class contains :
OnError:- To be called on any error encountered.
- Receives in argument the
WSClientGWrapperErrorArgs:- This class contains :
Message: the error message.Endpoint: the current URI where the WebSocket is connected to it.\Wrapper: is the current wrapper object.
- This class contains :
- Now we need to connect the WebSocket and start listening by calling the connect method :
wrapper.Connect();
If you need to change the WebSocket URI without connecting the socket, use the RebuildClient(string baseAddress, bool fixRemoteCertValidation = false)
If you need to change the WebSocket URI and create a new connection, call the RebuildClientAndConnect(string baseAddress, bool fixRemoteCertValidation = false).
Disconnect the WebSocket :
- To disconnect the client, use the disconnect method.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. 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.
-
net6.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 |
|---|