Esempio n. 1
0
 @Override
 protected void channelRead(
     final C connection,
     final DefaultContext context,
     final ChannelHandlerContext chctx,
     final Object msg)
     throws Exception {
   if (connection != null) {
     // we are reading from the channel
     Channel ch = chctx.channel();
     // We need to do this since it's possible the server is being used from a worker context
     if (context.isOnCorrectWorker(ch.eventLoop())) {
       try {
         vertx.setContext(context);
         doMessageReceived(connection, chctx, msg);
       } catch (Throwable t) {
         context.reportException(t);
       }
     } else {
       context.execute(
           new Runnable() {
             public void run() {
               try {
                 doMessageReceived(connection, chctx, msg);
               } catch (Throwable t) {
                 context.reportException(t);
               }
             }
           });
     }
   } else {
     try {
       doMessageReceived(connection, chctx, msg);
     } catch (Throwable t) {
       chctx.pipeline().fireExceptionCaught(t);
     }
   }
 }