Channel.write(Object obj)
    MichaelW86 
    fox_mpxygyu at kurzepost.de
       
    Wed Jan  6 15:34:30 EST 2010
    
    
  
Hallo
I'm trying to use Netty for a Socket Server but i have problems to write a
message to the downstream channel. When i use the channel.write() Method the
Exception: java.lang.UnsupportedOperationException is returned by the
corresponding future.getCause() Method. I think i do something wrong... 
Here is the Server Code:
/***********************************************************************************/
/* Class NJServer */
public class NJServer {
  public static void main(String[] args) throws Exception {
    new NJServer();
  }
	
 public NJServer() {
  this.factory = new NioServerSocketChannelFactory(
      Executors.newCachedThreadPool(),
      Executors.newCachedThreadPool());
  this.bootstrap = new ServerBootstrap(factory);
  bootstrap.setPipelineFactory(new NJServerPipelineFactory());
		
  this.channel = bootstrap.bind(new InetSocketAddress(1234));
  allChannels.add(channel);
  byte commando = 1;
  [...]
  ChannelBuffer buf = ChannelBuffers.buffer(16);
  buf.writeByte(commando);
  [...]
  /* HERE IS THE PROBLEM */
  f = this.channel.write(buf);
  f.addListener(new ChannelFutureListener() {
    public void operationComplete(ChannelFuture future) {
      if (future.isSuccess()) { [...] }
      else { System.out.print(future.getCause()); }
    }
  });
  waitForShutdownCommand();
  [...]
 }
}
			
/* Class NJServerPipelineFactory */
[...]
pipeline.addLast("handler", new NJServerHandler());
[...]
/* Class NJServerHandler */
[...]
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) {
  e.getChannel().getPipeline().addFirst("encoder", new NJMessageEncoder());
  e.getChannel().getPipeline().addFirst("decoder", new NJMessageDecoder());
}
[...]
/***********************************************************************************/
The NJMessageEncoder is never called!! The NJMessageDecoder works. So whats
the problem? The Client Application is a Java Socket Client, where Netty is
not used.
Thanks in advance!
Michael 
		
-- 
View this message in context: http://n2.nabble.com/Channel-write-Object-obj-tp4263112p4263112.html
Sent from the Netty User Group mailing list archive at Nabble.com.
    
    
More information about the netty-users
mailing list