Getting variables from/ Handlers

Bruno Mello bruno.mello at sapo.pt
Thu Mar 11 19:13:46 EST 2010


Hi all,

I'm new to Java NIO and fortunately Netty is helping me a lot on an academic
project. I really appreciate and thank the effort of Netty developers.

My application is based on the Factorial Example so it has 3 classes:
MWServer, MWServerHandler and MWServerPipelineFactory.

I need to send messages from another Java process through my application
(eventually using Java RMI), so I want to "detach" the
ctx.getChannel().write() from the MWServerHandler and use it on a different
class.

For instance:

public class MyApp {
   public static void main(final String[] args) {
      // setup websocket server
      WebSocketServer wss = new WebSocketServer(PORT);
      wss.run();
      
      wss.send("hello");
   }
}

The example is just illustration, because the send() method will be called
trough RMI. This means I need to access an instance of MWServerHandler in
order to get the ChannelHandlerContext.

So far, what I've tried was to create a private CTX variable in
MWServerHandler, then get it on the MWServerPipelineFactory (where the
Handler is created), then get it from MWServer (where the PipelineFactory is
create). This is not working, because the handlers are created in different
threads.

My question is: is it possible to send messages from outside the Handler?
How?
-- 
View this message in context: http://n2.nabble.com/Getting-variables-from-Handlers-tp4719574p4719574.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list