Sorry, a little add. In my last question i've forgotten to mention that i'm going to save MyClient objects in session.
velytreuzien wrote: > > Thanks! > > To clarify - we can think about some continious client update. Is it > better to use separate "logic" thread or sessionIdle() method with very > small update time? > > And one more question. Actually, the data sent to the clients differs and > so i need a client object. Is it safe enough to create my MyClient object > on sessionCreated(), don't store it separately in any list but use > session.getService().getManagedSessions(session.getServiceAddress()); and > do all finalization on sessionClosed()? > I mean am i supposed to do syncronization manually if i use these clients > in separate "logic" thread where i send my updates? > > > Maarten Bosteels-4 wrote: >> >> 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 >>> . >>> >> >> > > -- View this message in context: http://www.nabble.com/Send-socket-message-from-server-without-handling-messageReceived-tf4125888s16868.html#a11735364 Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.