private void pollHost ( BrokerSession session ) { Request request = ! enabled ? null : getRequest ( session . pollingAction ( ) , session ) ; if ( request == null ) { return ; } try { Response response = session . netCall ( request , 1000 ) ; String results [ ] = response . getData ( ) . split ( Constants . LINE_SEPARATOR , 2 ) ; String params [ ] = StrUtil . split ( results [ 0 ] , StrUtil . U , 2 ) ; switch ( response . getResponseType ( ) ) { case ACK : // A simple server acknowledgement int i = StrUtil . toInt ( params [ 0 ] ) ; if ( i > 0 ) { pollingInterval = i * 1000 ; } FMDate hostTime = new FMDate ( params [ 1 ] ) ; session . setHostTime ( hostTime ) ; break ; case ASYNC : // Completed asynchronous RPC int asyncHandle = StrUtil . toInt ( params [ 0 ] ) ; int asyncError = StrUtil . toInt ( params [ 1 ] ) ; if ( asyncHandle > 0 ) { if ( asyncError != 0 ) { session . onRPCError ( asyncHandle , asyncError , results [ 1 ] ) ; } else { session . onRPCComplete ( asyncHandle , results [ 1 ] ) ; } } break ; case EVENT : // Global event for delivery List < IHostEventHandler > hostEventHandlers = session . getHostEventHandlers ( ) ; if ( hostEventHandlers != null ) { try { String eventName = results [ 0 ] ; Object eventData = SerializationMethod . deserialize ( results [ 1 ] ) ; for ( IHostEventHandler hostEventHandler : hostEventHandlers ) { try { hostEventHandler . onHostEvent ( eventName , eventData ) ; } catch ( Throwable e ) { log . error ( "Host event subscriber threw an exception" , e ) ; } } } catch ( Throwable e ) { log . error ( "Error processing host event" , e ) ; } } break ; } } catch ( Throwable e ) { log . error ( "Error processing polling response." , e ) ; terminate ( ) ; } }
Polls the host at the specified interval for asynchronous activity .