@Override
  public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
          throws Exception {
    if (msg instanceof CreateStreamCommand) {
      createStream((CreateStreamCommand) msg, promise);
    } else if (msg instanceof SendGrpcFrameCommand) {
      sendGrpcFrame(ctx, (SendGrpcFrameCommand) msg, promise);
    } else if (msg instanceof CancelClientStreamCommand) {
      cancelStream(ctx, (CancelClientStreamCommand) msg, promise);
    } else if (msg instanceof SendPingCommand) {
      sendPingFrame(ctx, (SendPingCommand) msg, promise);
    } else if (msg instanceof GracefulCloseCommand) {
      gracefulClose(ctx, (GracefulCloseCommand) msg, promise);
    } else if (msg instanceof ForcefulCloseCommand) {
      forcefulClose(ctx, (ForcefulCloseCommand) msg, promise);
    } else if (msg == NOOP_MESSAGE) {
      ctx.write(Unpooled.EMPTY_BUFFER, promise);
    } else {
      throw new AssertionError("Write called for unexpected type: " + msg.getClass().getName());
    }
  }
@ Override public void write ( ChannelHandlerContext ctx , Object msg , ChannelPromise promise ) throws Exception { if ( msg instanceof CreateStreamCommand ) { createStream ( ( CreateStreamCommand ) msg , promise ) ; } else if ( msg instanceof SendGrpcFrameCommand ) { sendGrpcFrame ( ctx , ( SendGrpcFrameCommand ) msg , promise ) ; } else if ( msg instanceof CancelClientStreamCommand ) { cancelStream ( ctx , ( CancelClientStreamCommand ) msg , promise ) ; } else if ( msg instanceof SendPingCommand ) { sendPingFrame ( ctx , ( SendPingCommand ) msg , promise ) ; } else if ( msg instanceof GracefulCloseCommand ) { gracefulClose ( ctx , ( GracefulCloseCommand ) msg , promise ) ; } else if ( msg instanceof ForcefulCloseCommand ) { forcefulClose ( ctx , ( ForcefulCloseCommand ) msg , promise ) ; } else if ( msg == NOOP_MESSAGE ) { ctx . write ( Unpooled . EMPTY_BUFFER , promise ) ; } else { throw new AssertionError ( "Write called for unexpected type: " + msg . getClass ( ) . getName ( ) ) ; } }
Handler for commands sent from the stream.