Woof.WebSocket
5.2.0
Prefix Reserved
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
<PackageReference Include="Woof.WebSocket" Version="5.2.0" />
paket add Woof.WebSocket --version 5.2.0
#r "nuget: Woof.WebSocket, 5.2.0"
// 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
andClient
classes, implementIAuthenticationProvider
andISessionProvider
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
andServer
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 theException
property of theDecodeResult
in yourOnMessageReceived
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
andIsUnauthorized
true
inDecodeResult
. 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 | Versions 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. |
-
net5.0
- protobuf-net (>= 3.0.101)
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 | 495 | 7/14/2021 | |
5.1.0 | 476 | 6/30/2021 | |
5.0.0 | 454 | 6/24/2021 | |
1.2.1 | 453 | 6/9/2021 | |
1.2.0 | 414 | 3/19/2021 | |
1.1.9 | 439 | 2/15/2021 | |
1.1.8 | 425 | 2/15/2021 | |
1.1.7 | 563 | 10/24/2020 | |
1.1.6 | 506 | 10/24/2020 | |
1.1.5 | 523 | 10/24/2020 | |
1.1.4 | 549 | 10/24/2020 | |
1.1.3 | 590 | 10/24/2020 | |
1.1.2 | 543 | 10/23/2020 | |
1.1.1 | 588 | 9/13/2020 | |
1.1.0 | 580 | 9/13/2020 | |
1.0.2 | 519 | 9/11/2020 | |
1.0.1 | 566 | 9/9/2020 | |
1.0.0 | 550 | 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.