Emulating a sessions in Netty server.

Frederic Bregier fredbregier at free.fr
Tue Apr 21 16:01:04 EDT 2009


I forgot, you have to change @ChannelPipelineCoverage("all") to
@ChannelPipelineCoverage("one") since the factory will get you a new
pipeline for each channel.

Frederic

Frederic Bregier wrote:
> 
> Hi Karasko,
> 
> You can use a ConcurrentHashMap. For the ID, you can use if you want the
> channel.getId().
> 
> Also, if you implement your business handler (the last in the pipeline)
> such that this handler is new for every channel connection, then you have
> directly the possibility to implement your own data for the session in
> this handler.
> To do that (according to your other post), it could be something like:
> ServerPipelineFactory.java
> <code>
>    public ChannelPipeline getPipeline() throws Exception {
>         ChannelPipeline pipeline = pipeline();
>         pipeline.addLast("cmdDecoder", new MyCommandDecoder());
>         pipeline.addLast("stringEncoder", new StringEncoder("UTF-8"));
>         MyHandlerObj handler = new ServerHandlerObj(); 
>         pipeline.addLast("handler", handler);
>         return pipeline;
>     }
> </code> 
> Then in you MyHandlerObj, you could have your own data as private
> attribute of the class.
> Therefore, each data will be attached to one specific channel.
> 
> HTH
> Frederic
> 
> Karasko wrote:
>> 
>> Please help how to implement a session like behaviour on server.
>> Example: a user connect to the server, a unique ID is generated, than
>> user can be identified by this ID.
>> 
>> Can i use a ConcurrentHashMap to store this values ? Put on connect,
>> remove on connection close...
>> 
>> Or any advice ? :confused:
>> 
> 
> 


-----
Hardware/Software Architect
-- 
View this message in context: http://n2.nabble.com/Emulating-a-sessions-in-Netty-server.-tp2668498p2672218.html
Sent from the Netty User Group mailing list archive at Nabble.com.




More information about the netty-users mailing list