Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return close code from WebSocketClient.run/connect #58

Merged
merged 8 commits into from
Apr 18, 2024
Merged

Conversation

adam-fowler
Copy link
Member

  • Return close code from WebSocketHandler. This is ignored by the server but passed back to the user when using the client
  • Also throw errors, caused by closing WebSocket channel, Server should report these but otherwise ignore them. Client throws them

@@ -186,14 +187,14 @@ extension WebSocketClient {
/// - eventLoopGroup: EventLoopGroup to run WebSocket client on
/// - logger: Logger
/// - process: Closure handling webSocket
public static func connect(
@discardableResult public static func connect(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's document the return here e.g. when it's nil

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok good point

@@ -112,7 +113,7 @@ public struct WebSocketClient {
#endif

/// Connect and run handler
public func run() async throws {
@discardableResult public func run() async throws -> WebSocketErrorCode? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document the return here

@adam-fowler
Copy link
Member Author

@Joannis this has had some minor changes

  • Return close code and reason
  • Added WebSocketOutboundWrite.close function to allow for users to write custom close codes, reasons

@adam-fowler adam-fowler merged commit 1b9bdfc into main Apr 18, 2024
3 of 4 checks passed
@adam-fowler adam-fowler deleted the rt-close-code branch April 18, 2024 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants