mirror of
https://github.com/apple/swift-nio
synced 2026-11-27 05:04:22 +00:00
rename ctx to context (#842)
Motivation: `ctx` was always an abbreviation was 'context` and in Swift we don't really use abbreviations, so let's fix it. Modifications: - rename all instances of `ctx` to `context` Result: - fixes #483
This commit is contained in:
1 parent
862533d089
commit
a41280919e
55 files changed
+1287
-1285
No files matched your search
@@ -25,20 +25,20 @@ public final class WebSocketProtocolErrorHandler: ChannelInboundHandler {
|
||||
|
||||
public init() { }
|
||||
|
||||
public func errorCaught(ctx: ChannelHandlerContext, error: Error) {
|
||||
public func errorCaught(context: ChannelHandlerContext, error: Error) {
|
||||
if let error = error as? NIOWebSocketError {
|
||||
var data = ctx.channel.allocator.buffer(capacity: 2)
|
||||
var data = context.channel.allocator.buffer(capacity: 2)
|
||||
data.write(webSocketErrorCode: WebSocketErrorCode(error))
|
||||
let frame = WebSocketFrame(fin: true,
|
||||
opcode: .connectionClose,
|
||||
data: data)
|
||||
ctx.writeAndFlush(self.wrapOutboundOut(frame)).whenComplete { (_: Result<Void, Error>) in
|
||||
ctx.close(promise: nil)
|
||||
context.writeAndFlush(self.wrapOutboundOut(frame)).whenComplete { (_: Result<Void, Error>) in
|
||||
context.close(promise: nil)
|
||||
}
|
||||
}
|
||||
|
||||
// Regardless of whether this is an error we want to handle or not, we always
|
||||
// forward the error on to let others see it.
|
||||
ctx.fireErrorCaught(error)
|
||||
context.fireErrorCaught(error)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user