Can't find appropriate examples of what I'm trying to achieve with Netty

NiPNi nils-petter at nilsen.as
Fri May 29 06:13:05 EDT 2009


Excellent, this most certainly helps :-)

/NiPNi


christian wrote:
> 
> Hi NiPNi,
> 
> On Fri, May 29, 2009 at 10:13 AM, NiPNi <nils-petter at nilsen.as> wrote:
>>
> [...]
>> I'm having some difficulties formulating the actual question here,
>> because
>> this is all new to me (I usually work at a higher level, with webapps and
>> JBoss and such).
>>
>> My main issue, I think, is the fact that the response to a request is
>> produced asynchronously, so that from Netty's point of view, it's not a
>> response per se, but rather an unsolicited message initiated from the
>> server
>> side.
>>
>> This means that I have to keep track of the connections. The clients do
>> have
>> a logical ID that will be used in the higher-level applications, so I can
>> use that as a key to map the connections, but I don't have a clue what to
>> map.
> 
> Each channel (which is a tcp or udp connection) has an ID (getId()),
> you should map your logical ID to the channel ID. If you use a
> ChannelGroup (see the Javadoc, it is pretty good) you can get the
> client connection (Channel) back using its ID and send back the
> response.
> 
>> What I'm looking for with this post are actually two things
>> - a confirmation that this sort of server is even possible to make with
>> Netty
> 
> sure, most certainly!
> 
>> - a pointer or example on how to attack this problem; the examples I've
>> found are good, but too simple to be of much help given my limited
>> experience in this field
> 
> see above.
> - Store the channel in the ChannelGroup when channelConnected() is
> called by netty
> - store the mapping of the Channel ID and your ID when you get your
> logical ID (when messageReceived() is called)
> - when your backend processing is done, get the channel id from your
> mapping, with that Id get the channel from ChannelGroup
> - use the channel to send back the reply
> 
> Hth,
> regards,
> christian!
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
> 
> 

-- 
View this message in context: http://n2.nabble.com/Can%27t-find-appropriate-examples-of-what-I%27m-trying-to-achieve-with-Netty-tp2992637p2993081.html
Sent from the Netty User Group mailing list archive at Nabble.com.




More information about the netty-users mailing list