Hi guys,

i started to testing MINA the last days for using in a SMTPServer. So far im very impressed. I wrote some IoFilters by extending IoFilterAdapter and all works fine.

Now i stuck on a new IoFilter. I want to catch a message which is send from the Server and write on Char of the message per line to the client.

I tried this code but it always write the original response:

----------------------------------------------------
public class ThrottlingFilter extends IoFilterAdapter {

   @Override
public void messageSent(NextFilter arg0, IoSession arg1, Object arg2) throws Exception {

       if (arg2 instanceof String) {
           String response = (String) arg2;
for (int i = 0; i < response.length(); i++) {
               super.messageSent(arg0, arg1, response.charAt(i));
           }
       } else {
           super.messageSent(arg0, arg1, arg2);
       }
   }
}

-------------------------------------------------------

I checked that it reach the loop by putting some debug code in it.. So thats not the problem.

Any one can tell me what i did wrong ?

The other question is howto "sleep" for a given time before send response. Is Thread.sleep(long) ok in a IoFilter ?

Thx
Norman



Reply via email to