On 1/3/11 8:35 AM, Muhammad Ichsan wrote:
Dear All

I want to do stresstest from SocketAcceptor into remote client
application. So, when the remote app connects to this server, the
server will send many messages periodically.

My question is, in SocketAcceptor, which IoSession can be used to send
the messages? Is it inside sessionOpened(IoSession session)?
SocketAcceptor is just used to *accept* incoming new session. When the new session has been created, then it's processed by a IoProcessor, which uses a chain of filter at the end of which you have an IoHandler used to implement your pplication logic.

So if you want to write some message in a session, do it in your application implementing the IoHandler interface. The good candidate will be to do that in the messageReceived( IoSession session, Object message) event, where the session is present.
Why I ask this, because I see that in SocketConnector, I can't use
session in sessionOpened(IoSession session). Instead, I must use in
the connector.connect().awaitUninterruptibly().getSession().
remember that those methods are just called responding to events. hen the session has been created, the sessionCreated') followed by sessionOpen() will be sent, but it's just for your application to know about it. Depending on what you want to do (client or server), you may use the session (client) to send a message or get the session from the messageReceived (server) to wrote back a response.

Hope it helps.
Thanks



--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com

Reply via email to