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

Don't use next(isolation:) as it has OS requirements #77

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions Sources/HummingbirdWSCore/WebSocketHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ package actor WebSocketHandler {
handler: @escaping WebSocketDataHandler<Context>,
context: Context
) async throws -> WebSocketCloseFrame? {
let webSocketOutbound = WebSocketOutboundWriter(handler: self)
var inboundIterator = inbound.makeAsyncIterator()
let webSocketInbound = WebSocketInboundStream(
iterator: inboundIterator,
handler: self
)
try await withGracefulShutdownHandler {
let webSocketOutbound = WebSocketOutboundWriter(handler: self)
var inboundIterator = inbound.makeAsyncIterator()
let webSocketInbound = WebSocketInboundStream(
iterator: inboundIterator,
handler: self
)
let closeCode: WebSocketErrorCode
do {
// handle websocket data and text
Expand All @@ -179,21 +179,12 @@ package actor WebSocketHandler {
try await self.close(code: closeCode)
if case .closing = self.closeState {
// Close handshake. Wait for responding close or until inbound ends
#if compiler(>=6.0)
while let frame = try await inboundIterator.next(isolation: self) {
if case .connectionClose = frame.opcode {
try await self.receivedClose(frame)
break
}
}
#else
while let frame = try await inboundIterator.next() {
if case .connectionClose = frame.opcode {
try await self.receivedClose(frame)
break
}
}
#endif
}
// don't propagate error if channel is already closed
} catch ChannelError.ioOnClosedChannel {}
Expand Down
Loading