public void register ( Session session , int ops ) throws ClosedChannelException { if ( sessions . containsKey ( session . getID ( ) ) ) { throw new IllegalStateException ( "Altready registered session" ) ; } SelectionKey selKey ; try { selKey = session . getChannel ( ) . register ( selector , ops , session ) ; } catch ( ClosedChannelException e ) { Logger . error ( "Error while register channel to selector. {}" , session , e ) ; throw e ; } session . setSelectionKey ( selKey ) ; }
register session to Selector in order to detect IO events .