Skip to content
New issue

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

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

Already on GitHub? # to your account

Strict concurrency for the chat examples #3104

Merged
merged 4 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
9 changes: 6 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ let package = Package(
"NIOCore",
"NIOConcurrencyHelpers",
],
exclude: ["README.md"]
exclude: ["README.md"],
swiftSettings: strictConcurrencySettings
),
.executableTarget(
name: "NIOChatClient",
Expand All @@ -343,7 +344,8 @@ let package = Package(
"NIOCore",
"NIOConcurrencyHelpers",
],
exclude: ["README.md"]
exclude: ["README.md"],
swiftSettings: strictConcurrencySettings
),
.executableTarget(
name: "NIOWebSocketServer",
Expand All @@ -370,7 +372,8 @@ let package = Package(
dependencies: [
"NIOPosix",
"NIOCore",
]
],
swiftSettings: strictConcurrencySettings
),
.executableTarget(
name: "NIOUDPEchoServer",
Expand Down
4 changes: 3 additions & 1 deletion Sources/NIOChatClient/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ let bootstrap = ClientBootstrap(group: group)
// Enable SO_REUSEADDR.
.channelOption(.socketOption(.so_reuseaddr), value: 1)
.channelInitializer { channel in
channel.pipeline.addHandler(ChatHandler())
channel.eventLoop.makeCompletedFuture {
try channel.pipeline.syncOperations.addHandler(ChatHandler())
}
}
defer {
try! group.syncShutdownGracefully()
Expand Down
4 changes: 2 additions & 2 deletions Sources/NIOMulticastChat/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
var datagramBootstrap = DatagramBootstrap(group: group)
.channelOption(.socketOption(.so_reuseaddr), value: 1)
.channelInitializer { channel in
channel.pipeline.addHandler(ChatMessageEncoder()).flatMap {
channel.pipeline.addHandler(ChatMessageDecoder())
channel.eventLoop.makeCompletedFuture {
try channel.pipeline.syncOperations.addHandlers(ChatMessageEncoder(), ChatMessageDecoder())
}
}

Expand Down
Loading