On Tue, Jan 26, 2010 at 6:38 AM, Michael Clifford <[email protected]> wrote: > Ahh, ok. I may be thinking about it differently, because my program is not > just serving lots of hosts. It's taking data from each individual host and > combining them using some fairly complex logic, so eventually, I must get my > data out of the sessions, and into the core of my program. > > So let me see if I understand this correctly: > > 1) Every time something connects to my server, a session is automatically > created. I don't have to do anything extra to create it.
Yes > 2) Sessions contain all of the info about a connection Sort of yes .. > 3) When something sends a message to one of my sessions, that session is > automagically called. I don't need to do anything, and I don't need to > iterate over them. Absolutely correct :-) > 4) I can write a filter to have the session do the parsing for me, so I just > need to handle the string that it outputs if I choose to do that. > > Is that correct? Yes that's correct > > So then if I store the string as an attribute, I would need to place each new > session into a container, and then iterate over all the sessions, read the > strings out of them, and do something with those strings? Then I'd also need > to check each session to see if it was connected, because it might have > closed in the mean time, and then I'd want to read out the last string and > stop tracking it. Lost here :-( Not sure what you want to do with Strings.. Essentially in your IoHandler, on messageReceived() you process the message, like persist it to DB, log etc, and send a response back. What Emm, was trying to point out is that, you may receive fragmented msg, your String could be part of two packets and that's the situation you have to deal to with in your filter. There are couple of examples around this, so feel free to experiment. -- thanks ashish
