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

Websocket 2.x.x #33

Merged
merged 16 commits into from
Jan 26, 2024
Merged

Websocket 2.x.x #33

merged 16 commits into from
Jan 26, 2024

Conversation

adam-fowler
Copy link
Member

@adam-fowler adam-fowler commented Jan 2, 2024

All changes are in WebSockets module. All other code is ignored at the moment. Because I haven't implemented a web socket client I haven't added any tests just yet.

let app = HBApplication(
    router: router,
    server: .httpAndWebSocket { channel, head in
        if head.uri == "ws" {
            return .upgrade(HTTPHeaders()) { inbound, outbound, _ in
                for try await packet in inbound {
                    if case .text("disconnect") = packet {
                        break
                    }
                    try await outbound.write(.custom(packet.webSocketFrame))
                }
            }
        } else {
            return .dontUpgrade
        }
    }
)

This is not complete by any measure but gives us an idea what a websocket solution might look like

@adam-fowler adam-fowler marked this pull request as draft January 2, 2024 17:04
Copy link

codecov bot commented Jan 4, 2024

Codecov Report

Attention: 320 lines in your changes are missing coverage. Please review.

Comparison is base (397f41e) 85.92% compared to head (64001d4) 0.00%.

Files Patch % Lines
...ources/HummingbirdWebSocket/WebSocketHandler.swift 0.00% 121 Missing ⚠️
...birdWebSocket/Server/WebSocketChannelHandler.swift 0.00% 78 Missing ⚠️
.../HummingbirdWebSocket/WebSocketInboundStream.swift 0.00% 34 Missing ⚠️
...bSocket/Server/NIOWebSocketServerUpgrade+ext.swift 0.00% 26 Missing ⚠️
...WebSocket/Server/WebSocketHTTPChannelBuilder.swift 0.00% 22 Missing ⚠️
...HummingbirdWebSocket/WebSocketOutboundWriter.swift 0.00% 21 Missing ⚠️
...es/HummingbirdWebSocket/WebSocketDataHandler.swift 0.00% 10 Missing ⚠️
...ources/HummingbirdWebSocket/WebSocketContext.swift 0.00% 4 Missing ⚠️
.../HummingbirdWebSocket/WebSocketFrameSequence.swift 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            2.x.x     #33       +/-   ##
==========================================
- Coverage   85.92%   0.00%   -85.93%     
==========================================
  Files          11       9        -2     
  Lines         995     349      -646     
==========================================
- Hits          855       0      -855     
- Misses        140     349      +209     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@adam-fowler adam-fowler marked this pull request as ready for review January 25, 2024 07:55
@adam-fowler adam-fowler merged commit f167a3b into 2.x.x Jan 26, 2024
3 of 5 checks passed
@adam-fowler adam-fowler deleted the websocket-2.x.x branch January 26, 2024 19:55
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.

2 participants