Remove no needed return statements and cleanup examples.
Motivation: We do not need to use return in the closures used in the examples. Modifications: - Remove return - Remove bug where we set the same channel option two times in one example Result: Cleaner code.
This commit is contained in:
parent
0e7b90ef16
commit
3f4a755de1
|
@ -25,8 +25,8 @@
|
|||
/// // Set the handlers that are appled to the accepted child `Channel`s.
|
||||
/// .childChannelInitializer { channel in
|
||||
/// // Ensure we don't read faster then we can write by adding the BackPressureHandler into the pipeline.
|
||||
/// return channel.pipeline.add(handler: BackPressureHandler()).then { () in
|
||||
/// return channel.pipeline.add(handler: MyChannelHandler())
|
||||
/// channel.pipeline.add(handler: BackPressureHandler()).then { () in
|
||||
/// channel.pipeline.add(handler: MyChannelHandler())
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
|
|
|
@ -122,9 +122,9 @@ let bootstrap = ServerBootstrap(group: group)
|
|||
// Set the handlers that are appled to the accepted Channels
|
||||
.childChannelInitializer { channel in
|
||||
// Add handler that will buffer data until a \n is received
|
||||
return channel.pipeline.add(handler: LineDelimiterCodec()).then { v in
|
||||
channel.pipeline.add(handler: LineDelimiterCodec()).then { v in
|
||||
// Its important we use the same handler for all accepted channels. The ChatHandler is thread-safe!
|
||||
return channel.pipeline.add(handler: chatHandler)
|
||||
channel.pipeline.add(handler: chatHandler)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,6 @@ private final class EchoHandler: ChannelInboundHandler {
|
|||
|
||||
let group = MultiThreadedEventLoopGroup(numThreads: 1)
|
||||
let bootstrap = ClientBootstrap(group: group)
|
||||
.channelOption(ChannelOptions.socket(SocketOptionLevel(SOL_SOCKET), SO_REUSEADDR), value: 1)
|
||||
// Enable SO_REUSEADDR.
|
||||
.channelOption(ChannelOptions.socket(SocketOptionLevel(SOL_SOCKET), SO_REUSEADDR), value: 1)
|
||||
.channelInitializer { channel in
|
||||
|
|
|
@ -49,8 +49,8 @@ let bootstrap = ServerBootstrap(group: group)
|
|||
// Set the handlers that are appled to the accepted Channels
|
||||
.childChannelInitializer { channel in
|
||||
// Ensure we don't read faster then we can write by adding the BackPressureHandler into the pipeline.
|
||||
return channel.pipeline.add(handler: BackPressureHandler()).then { v in
|
||||
return channel.pipeline.add(handler: EchoHandler())
|
||||
channel.pipeline.add(handler: BackPressureHandler()).then { v in
|
||||
channel.pipeline.add(handler: EchoHandler())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -395,8 +395,8 @@ let bootstrap = ServerBootstrap(group: group)
|
|||
|
||||
// Set the handlers that are applied to the accepted Channels
|
||||
.childChannelInitializer { channel in
|
||||
return channel.pipeline.addHTTPServerHandlers().then { _ in
|
||||
return channel.pipeline.add(handler: HTTPHandler(fileIO: fileIO, htdocsPath: htdocs))
|
||||
channel.pipeline.addHTTPServerHandlers().then { _ in
|
||||
channel.pipeline.add(handler: HTTPHandler(fileIO: fileIO, htdocsPath: htdocs))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue