@@ -46,56 +46,56 @@ open class IRCChannelHandler : ChannelDuplexHandler {
4646
4747 public init ( ) { }
4848
49- open func channelActive( ctx : ChannelHandlerContext ) {
50- ctx . fireChannelActive ( )
49+ open func channelActive( context : ChannelHandlerContext ) {
50+ context . fireChannelActive ( )
5151 }
52- open func channelInactive( ctx : ChannelHandlerContext ) {
53- ctx . fireChannelInactive ( )
52+ open func channelInactive( context : ChannelHandlerContext ) {
53+ context . fireChannelInactive ( )
5454 }
5555
5656
5757 // MARK: - Reading
5858
5959 var parser = IRCMessageParser ( )
6060
61- open func channelRead( ctx : ChannelHandlerContext , data: NIOAny ) {
61+ open func channelRead( context : ChannelHandlerContext , data: NIOAny ) {
6262 let buffer = self . unwrapInboundIn ( data)
6363
6464 parser. feed ( buffer) { error, message in
6565 if let message = message {
66- channelRead ( ctx : ctx , value: message)
66+ channelRead ( context : context , value: message)
6767 }
6868 if let error = error {
69- ctx . fireErrorCaught ( error)
69+ context . fireErrorCaught ( error)
7070 }
7171 }
7272 }
7373
74- open func channelRead( ctx : ChannelHandlerContext , value: InboundOut ) {
75- ctx . fireChannelRead ( self . wrapInboundOut ( value) )
74+ open func channelRead( context : ChannelHandlerContext , value: InboundOut ) {
75+ context . fireChannelRead ( self . wrapInboundOut ( value) )
7676 }
7777
78- open func errorCaught( ctx : ChannelHandlerContext , error: Swift . Error ) {
79- ctx . fireErrorCaught ( InboundErr . transportError ( error) )
78+ open func errorCaught( context : ChannelHandlerContext , error: Swift . Error ) {
79+ context . fireErrorCaught ( InboundErr . transportError ( error) )
8080 }
8181
8282
8383 // MARK: - Writing
8484
85- public func write( ctx : ChannelHandlerContext , data: NIOAny ,
85+ public func write( context : ChannelHandlerContext , data: NIOAny ,
8686 promise: EventLoopPromise < Void > ? )
8787 {
8888 let message : OutboundIn = self . unwrapOutboundIn ( data)
89- write ( ctx : ctx , value: message, promise: promise)
89+ write ( context : context , value: message, promise: promise)
9090 }
9191
92- public final func write( ctx : ChannelHandlerContext , value: IRCMessage ,
92+ public final func write( context : ChannelHandlerContext , value: IRCMessage ,
9393 promise: EventLoopPromise < Void > ? )
9494 {
95- var buffer = ctx . channel. allocator. buffer ( capacity: 200 )
95+ var buffer = context . channel. allocator. buffer ( capacity: 200 )
9696 encode ( value: value, target: value. target, into: & buffer)
9797
98- ctx . write ( NIOAny ( buffer) , promise: promise)
98+ context . write ( NIOAny ( buffer) , promise: promise)
9999 }
100100
101101 func encode( value: IRCMessage , target: String ? ,
@@ -247,6 +247,40 @@ open class IRCChannelHandler : ChannelDuplexHandler {
247247 buffer. writeInteger ( cCR)
248248 buffer. writeInteger ( cLF)
249249 }
250+
251+ #if swift(>=5) // NIO 2 API - default
252+ #else // NIO 1 API shims
253+ open func channelActive( ctx context: ChannelHandlerContext ) {
254+ channelActive ( context: context)
255+ }
256+ open func channelInactive( ctx context: ChannelHandlerContext ) {
257+ channelInactive ( context: context)
258+ }
259+ open func channelRead( ctx context: ChannelHandlerContext , data: NIOAny ) {
260+ channelRead ( context: context, data: data)
261+ }
262+ open func channelRead( ctx context: ChannelHandlerContext ,
263+ value: InboundOut )
264+ {
265+ channelRead ( context: context, value: value)
266+ }
267+ open func errorCaught( ctx context: ChannelHandlerContext ,
268+ error: Swift . Error )
269+ {
270+ errorCaught ( context: context, error: error)
271+ }
272+ public func write( ctx context: ChannelHandlerContext , data: NIOAny ,
273+ promise: EventLoopPromise < Void > ? )
274+ {
275+ write ( context: context, data: data, promise: promise)
276+ }
277+ public final func write( ctx context: ChannelHandlerContext ,
278+ value: IRCMessage ,
279+ promise: EventLoopPromise < Void > ? )
280+ {
281+ write ( context: context, value: value, promise: promise)
282+ }
283+ #endif
250284}
251285
252286extension ByteBuffer {
0 commit comments