// netty can only handle bytes in the form of ByteBuf, so if you reach this then you are // perhaps trying to send a POJO without having a suitable encoder public override void write(ChannelHandlerContext ctx, object msg, ChannelPromise promise) { if (!(msg is ByteBuf)) { _outerInstance.log.error("Unhandled outbound message: %s for channel: %s", msg, ctx.channel()); ctx.close(); } else { ctx.write(msg, promise); } }
public override void Write(ChannelHandlerContext ctx, object msg, ChannelPromise promise) { if (!_gated.test(msg)) { ctx.write(msg, promise); } else if (_pending != null) { _pending.Add(new GatedWrite(msg, promise)); } else { promise.Failure = new Exception("Gate failed and has been permanently closed."); } }
// this is the first handler for an outbound message, and attaches a listener to its promise if possible public override void write(ChannelHandlerContext ctx, object msg, ChannelPromise promise) { // if the promise is a void-promise, then exceptions will instead propagate to the // exceptionCaught handler on the outbound handler further below if (!promise.Void) { promise.addListener((ChannelFutureListener)future => { if (!future.Success) { _outerInstance.swallow(() => _outerInstance.log.error(format("Exception in outbound for channel: %s", future.channel()), future.cause())); outerInstance.swallow(ctx.close); } }); } ctx.write(msg, promise); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) throws Exception public override void Write(ChannelHandlerContext ctx, object msg, ChannelPromise promise) { throw new Exception(Thread.CurrentThread.Name + " - This handler does not write"); }
/// <summary> /// Main event that is triggered for connections and swapping out SslHandler for this handler. channelActive and handlerAdded handlers are /// secondary boundary cases to this. /// </summary> /// <param name="ctx"> Context of the existing channel </param> /// <param name="remoteAddress"> the address used for initating a connection to a remote host (has type InetSocketAddress) </param> /// <param name="localAddress"> the local address that will be used for receiving responses from the remote host </param> /// <param name="promise"> the Channel promise to notify once the operation completes </param> /// <exception cref="Exception"> when there is an error of any sort </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void connect(io.netty.channel.ChannelHandlerContext ctx, java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, io.netty.channel.ChannelPromise promise) throws Exception public override void Connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) { SslHandler sslHandler = CreateSslHandler(ctx, ( InetSocketAddress )remoteAddress); ReplaceSelfWith(sslHandler); ctx.connect(remoteAddress, localAddress, promise); }
public override void write(ChannelHandlerContext ctx, object msg, ChannelPromise promise) { ctx.write(ctx.alloc().buffer()); }
public override void write(ChannelHandlerContext ctx, object msg, ChannelPromise promise) { throw _ex; }
internal GatedWrite(object msg, ChannelPromise promise) { this.Msg = msg; this.Promise = promise; }