statianzo / Fleck

C# Websocket Implementation
MIT License
2.25k stars 583 forks source link

Close with code added to interface #312

Closed localcc closed 3 years ago

localcc commented 3 years ago

There is Close(int code); method in WebSocketConnection, but no such method in Interface, so I added that to interface.

AppVeyorBot commented 3 years ago

:white_check_mark: Build Fleck 0.0.58-ci completed (commit https://github.com/statianzo/Fleck/commit/8529c8839f by @localcc)

AppVeyorBot commented 3 years ago

:white_check_mark: Build Fleck 0.0.58-ci completed (commit https://github.com/statianzo/Fleck/commit/8529c8839f by @localcc)

statianzo commented 3 years ago

I'm fine with bringing this in, but could you explain the scenario where you're needing to send a different code?

localcc commented 3 years ago

When client tries to authenticate, I check his headers for authentication token, etc. and I need to disconnect him with different reasons for different authentication errors (e.g. no user, invalid token, expired token)

statianzo commented 3 years ago

Makes sense. Just a heads up, as they are websocket status codes, using the 4000-4999 range is for applications.

https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent

statianzo commented 3 years ago

Published as 1.2.0

https://www.nuget.org/packages/Fleck/1.2.0