I think that would work. But if all you want to do is send "hello world" to every connected client, every 10 seconds, you could do it like this:
public void sessionCreated(IoSession session) throws Exception { session.setIdleTime(IdleStatus.WRITER_IDLE, 10); // this will generate a sessionIdle event whenever the session hasn't be written to for 10 seconds } public void sessionIdle(IoSession session, IdleStatus status) throws Exception { session.write("Hello World"); } Also note that there is an easier way to retrieve all current sessions: session.getService().getManagedSessions(session.getServiceAddress()); Maarten On 7/22/07, velytreuzien <[EMAIL PROTECTED]> wrote:
Greetings! Can i use MINA for developing server-side application that sends e.g. "Hello, World!" to each connected socket client say every 10 seconds? Let's suggest i override sessionCreated of IoHandlerAdapter and save all new IoSession into a list, but don't override messageReceived. Also, i create my own Runnable which constantly runs smth like: if (timeDelta >= 10000) { for (ioSession : sessionList) { session.write("Hello, World"); } } Will this work? Ant is there any solution in MINA that is simlier and doesn't require my own thread? -- View this message in context: http://www.nabble.com/Send-socket-message-from-server-without-handling-messageReceived-tf4125888s16868.html#a11733153 Sent from the Apache MINA Support Forum mailing list archive at Nabble.com .