On 5/12/11 2:21 PM, Muhammad Ichsan wrote:
On Thu, May 12, 2011 at 6:51 PM, Muhammad Ichsan<[email protected]>  wrote:
On Thu, May 12, 2011 at 6:21 PM, Emmanuel Lecharny<[email protected]>  wrote:
On 5/12/11 12:18 PM, Muhammad Ichsan wrote:
The session will be opened anyway. What you should do is to store a state in
the session, and send a message to the client when the sign-in has not been
done. Calling sessionOpened() in the messageReceived hs no effect and does
not send anything to the client. Do a session.write( "You first have to sign
it" ) instead (kind of)
Sorry, if sample is not clear. Let me re-write it

SignInFilter {

        sessionOpened(NextFilter nextFilter, IoSession session) {
                // Since sign-in shake is required,
                  // don't call: nextFilter.sessionOpened(session);
                session.write("You have to sign on"); // This message never be 
..
                   // received by remote server. Why???

So, this is my question: Why remote server never received "You have to
sign on" ???

You are probably not reading the response.

I have added this in the EchoProtocolHandler class in mina-example echoserver sample :
    public void sessionOpened(IoSession session) throws Exception {
        IoBuffer buf = IoBuffer.allocate("Sign in expected".length());
        buf.put("Sign in expected".getBytes());
        buf.flip();
        session.write( buf );
        LOGGER.info("OPENED");
    }


and I correctly receive the message :

$ telnet localhost 8080
Trying ::1...
Connected to localhost.
Escape character is '^]'.
Sign in expected <<--------------

test
test



        }

        messageReceived(NextFilter nextFilter, IoSession session, Object 
message) {
        // If sign in reply is received, allow connection to SocketHandler
        if (isSignInReply(message))
                        nextFilter.sessionOpened(session);
}

Thanks




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

Reply via email to