public synchronized void connectionEstablished ( PresentsConnection conn , Name authname , AuthRequest req , AuthResponse rsp ) { String type = authname . getClass ( ) . getSimpleName ( ) ; // see if a session is already registered with this name PresentsSession session = getClient ( authname ) ; if ( session != null ) { //log.info("Resuming session", "type", type, "who", authname, "conn", conn); session . resumeSession ( req , conn ) ; } else { log . info ( "Session initiated" , "type" , type , "who" , authname , "conn" , conn ) ; // figure out our session class Class < ? extends PresentsSession > sessionClass = null ; for ( SessionFactory factory : _factories ) { if ( ( sessionClass = factory . getSessionClass ( req ) ) != null ) { break ; } } // create a new session and stick'em in the table session = _injector . getInstance ( sessionClass ) ; session . startSession ( authname , req , conn , rsp . authdata ) ; // map their session instance synchronized ( _usermap ) { // we refetch the authname from the session for use in the map in case it decides // to do something crazy like rewrite it in startSession() _usermap . put ( session . getAuthName ( ) , session ) ; } } // map this connection to this session _conmap . put ( conn , session ) ; }
Called by the connection manager to let us know when a new connection has been established .