title: Netty client server login, how to have channelRead return a boolean
body: <p>I'm writing client server applications on top of netty.</p>
  <p>I'm starting with a simple client login server that validates info sent from the client with the database. This all works fine.</p>
  <p>On the client-side, I want to use If statements once the response is received from the server if the login credentials validate or not. which also works fine. My problem is the ChannelRead method does not return anything. I can not change this. I need it to return a boolean which allows login attempt to succeed or fail.</p>
  <p>Once the <code>channelRead()</code> returns, I lose the content of the data.</p>
  <p>I tried adding the msg to a List but, for some reason, the message data is not stored in the List.</p>
  <p>Any suggestions are welcome. I'm new... This is the only way I've figured out to do this. I have also tried using boolean statements inside <code>channelRead()</code> but these methods are void so once it closes the boolean variables are cleared.</p>
  <p>Following is the last attempt I tried to insert the message data into the list I created...</p>
  <pre><code>import io.netty.channel.ChannelHandlerContext;
  import io.netty.channel.ChannelInboundHandlerAdapter;
  
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.List;
  import java.util.ListIterator;
  
  public class LoginClientHandler extends ChannelInboundHandlerAdapter {
      Player player = new Player();
      String response;
      public volatile boolean loginSuccess;
  //    Object message = new Object();
      private Object msg;
      public static final List&lt;Object&gt; incomingMessage = new List&lt;Object&gt;() {
  
         
      @Override
      public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
  //        incomingMessage.clear();
          response = (String) msg;
          System.out.println(&quot;channel read response = &quot; + response);
          incomingMessage.add(0, msg);
          System.out.println(&quot;incoming message = &quot; + incomingMessage.get(0));
      }    
  </code></pre>
  <p>How can I get the message data &quot;out&quot; of the <code>channelRead()</code> method or use this method to create a change in my business logic? I want it to either display a message to tell the client login failed and try again or to succeed and load the next scene. I have the business logic working fine but I can't get it to work with netty because none of the methods return anything I can use to affect my business logic.</p>
  <p>ChannelInitializer</p>
  <pre><code>import io.netty.channel.ChannelInitializer;
  import io.netty.channel.ChannelPipeline;
  import io.netty.channel.socket.SocketChannel;
  import io.netty.handler.codec.DelimiterBasedFrameDecoder;
  import io.netty.handler.codec.Delimiters;
  import io.netty.handler.codec.string.StringDecoder;
  import io.netty.handler.codec.string.StringEncoder;
  
  public class LoginClientInitializer extends ChannelInitializer &lt;SocketChannel&gt; {
  
  
      @Override
      protected void initChannel(SocketChannel ch) throws Exception {
          ChannelPipeline pipeline = ch.pipeline();
  
          pipeline.addLast(&quot;framer&quot;, new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
          pipeline.addLast(&quot;decoder&quot;, new StringDecoder());
          pipeline.addLast(&quot;encoder&quot;, new StringEncoder());
  
          pipeline.addLast(&quot;handler&quot;, new LoginClientHandler());
      }
  }
  </code></pre>