Woof.WebSocket 5.2.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
Suggested Alternatives

Woof.Net.WebSockets

Additional Details

WebSockets is now a part of Woof.Net namespace. Some refactoring is needed to make the legacy code work with the new version, see the provided test projects on GitHub.

dotnet add package Woof.WebSocket --version 5.2.0
NuGet\Install-Package Woof.WebSocket -Version 5.2.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="Woof.WebSocket" Version="5.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Woof.WebSocket --version 5.2.0
#r "nuget: Woof.WebSocket, 5.2.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 Woof.WebSocket as a Cake Addin
#addin nuget:?package=Woof.WebSocket&version=5.2.0

// Install Woof.WebSocket as a Cake Tool
#tool nuget:?package=Woof.WebSocket&version=5.2.0

Woof.WebSocket

Full, high-level WebSocket client and server. Designed to make WebSocket APIs blazing fast.

Priority list:

  • ease of use,
  • code speed,
  • stability,
  • extensibility
  • completness.

Q/A:

Q: Dependencies?<br/> A: .NET 5.0, protobuf-net. Can be made to work with older frameworks, in order to do so use the source code, change the target framework, implement necessary changes.

Q: Thread-safe?<br/> A: Yes. Tested. Tested. Then tested some more.

Q: Asynchronous?<br/> A: Task based. Fully asynchronous.

Q: How? A: Override Server and Client classes, implement IAuthenticationProvider and ISessionProvider for authentication. See examples.

Q: How call SendMessageAsync() and friends in an event handler?<br/> A: Make the event handler "async void" and ensure no exceptions are thrown there. Pass exceptions as data when necessary.

Q: Will the server work with clients in other environments (non .NET)?<br/> A: Yes. WOOF codec uses compatible Google Protocol Buffer serializer available for many environments. It's relatively easy to make your own codec using JSON or any other object serializer.<br/>

Q: Why Protocol Buffers?<br/> A: Because it efficient (small serialized size), fast (simple algorithm, fixed size reads), well established (invented by Goolge, developed by active community).

Q: Where can I find an example of a client written in language x?<br/> A: Be the first to write it and don't forget to send a pull request.

Q: Can custom subprotocols be used with WebSocket transport?<br/> A: Yes. Any subprotocol can be used, all it takes is to implement SubProtocolCodec abstract class. Do JSON as an excercise 😉

Q: So why use this Client and Server without a subprotocol?<br/> A: A great deal of the transport hand-shaking already done. Tidy structure to implement. And you DO have a good WOOF subprotocol based on Protocol Buffers.

Q: Can it be done simpler?<br/> A: No. I really tried. This is as simple as it gets.

Q: Is that all?<br/> A: No. There will be streaming support soon. But don't hold your breath. Or just add it and send a pull request. Look at Skype: it uses another port (you can use just another endpoint, like a different path) to use separate server just for streaming data.

Q: Wow, neat DI there 😉 But what if my IAuthenticationProvider implementation throws an exception? I don't see it anywhere, is it a bug?<br/> A: Nope. It's a feature. Check the Exception property of the DecodeResult in your OnMessageReceived handler. It's there to be handled in your code.

Q: About the last one, isn't that dangerous? I can have non-breaking (silent) exception in authentication code.<br/> A: You still have IsSignatureValid false and IsUnauthorized true in DecodeResult. Do use them.

Usage:

First time: Pull the Git repository. See the provided examples. They contain full documentation in XMLdoc.<br/> Not first time: Just install Woof.WebSocket with NuGet.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  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. 
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
5.2.0 453 7/14/2021
5.1.0 437 6/30/2021
5.0.0 419 6/24/2021
1.2.1 415 6/9/2021
1.2.0 385 3/19/2021
1.1.9 407 2/15/2021
1.1.8 411 2/15/2021
1.1.7 529 10/24/2020
1.1.6 474 10/24/2020
1.1.5 491 10/24/2020
1.1.4 516 10/24/2020
1.1.3 559 10/24/2020
1.1.2 495 10/23/2020
1.1.1 552 9/13/2020
1.1.0 546 9/13/2020
1.0.2 484 9/11/2020
1.0.1 536 9/9/2020
1.0.0 518 9/6/2020

FIX: Now exceptions in IAuthentication provider are caught and passed in Exception property of DecodeResult. That allows them to be handled in OnMessageReceived handler.