store client specific information

miarkus miarkus at tlen.pl
Mon Jan 19 13:59:09 EST 2009


Hi Trustin,

thanks for your thorough answer. I have few more questions for you. Is there
a chance that updating, retrieving and removing clients from
ConcurrentHashMap will block each other as those operations will be
performed quite often in short timeframe. Moreover an executor will be
connecting to local mysql to check credentials of some clients.
Hypothetically how it can influence performance - should I expect vast
performance degradation?

Thanks again,

Pete

PS> Netty works so beautiful with actionscript 3 sockets :)


Trustin Lee-3 wrote:
> 
> Hi Pete,
> 
> Let me assume that you are writing a server and you want to maintain a
> map whose key is a user ID (e-mail address) and whose value is a
> Channel (connected from a client to the server).
> 
> Then, you can simply put a ConcurrentHashMap<String, Channel> field in
> your server-side handler (ChannelHandler), and put and remove entries
> as clients logs in and out.  To find a Channel associated with an
> e-mail address, you can call Map.get() to retrieve the associated
> Channel.  Now you can call Channel.write() to send a message to the
> client.  Please note that you can call Channel.write() from any
> thread, even outside of ChannelHandler's event handler methods because
> all methods in Channel are thread-safe - this will give you a lot of
> freedom in how you implement your server.
> 
> Please feel free to ask more questions if my answer was not clear enough.
> 
> HTH,
> 
> — Trustin Lee, http://gleamynode.net/
> 
> 
-- 
View this message in context: http://n2.nabble.com/store-client-specific-information-tp2176934p2182842.html
Sent from the Netty User Group mailing list archive at Nabble.com.





More information about the netty-users mailing list