コード例 #1
0
  @Override
  public void subscribe(Subscriber<? super Object> s) {
    if (log.isDebugEnabled()) {
      log.debug(
          "Subscribing inbound receiver [pending: "
              + ""
              + inboundEmitter.getPending()
              + ", done: "
              + inboundEmitter.done
              + "]");
    }
    if (inboundEmitter.actual == null) {
      if (inboundEmitter.done) {
        if (inboundEmitter.error != null) {
          Operators.error(s, inboundEmitter.error);
          return;
        } else if (inboundEmitter.getPending() == 0) {
          Operators.complete(s);
          return;
        }
      }

      inboundEmitter.init(s);
      s.onSubscribe(inboundEmitter);
    } else {
      Operators.error(
          s, new IllegalStateException("Only one connection receive subscriber allowed."));
    }
  }
コード例 #2
0
 @Override
 public void channelInactive(ChannelHandlerContext ctx) throws Exception {
   try {
     inboundEmitter.complete();
     super.channelInactive(ctx);
   } catch (Throwable err) {
     Exceptions.throwIfFatal(err);
     inboundEmitter.fail(err);
   }
 }
コード例 #3
0
 @SuppressWarnings("unchecked")
 protected final void doRead(Object msg) {
   if (msg == null) {
     return;
   }
   try {
     if (msg == Unpooled.EMPTY_BUFFER || msg instanceof EmptyByteBuf) {
       return;
     }
     inboundEmitter.next(msg);
   } catch (Throwable err) {
     Exceptions.throwIfFatal(err);
     inboundEmitter.fail(err);
   }
 }
コード例 #4
0
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, Throwable err) throws Exception {
   Exceptions.throwIfFatal(err);
   inboundEmitter.fail(err);
 }