public IoSession getSession ( ) { synchronized ( lock ) { if ( sessions . isEmpty ( ) ) { return null ; } else { final Object [ ] keys = sessions . keySet ( ) . toArray ( ) ; for ( int i = 0 ; i < sessions . size ( ) ; i ++ ) { // counter ++ ; final int pos = Math . abs ( counter % sessions . size ( ) ) ; final IoSession session = sessions . get ( keys [ pos ] ) ; if ( isAvailable ( session ) ) { return session ; } } return null ; } } }
Rotates via list of currently established sessions