public static ManagerResponse sendAction ( final ManagerAction action , final int timeout ) throws IllegalArgumentException , IllegalStateException , IOException , TimeoutException { if ( logger . isDebugEnabled ( ) ) CoherentManagerConnection . logger . debug ( "Sending Action: " + action . toString ( ) ) ; //$NON-NLS-1$ CoherentManagerConnection . getInstance ( ) ; if ( ( CoherentManagerConnection . managerConnection != null ) && ( CoherentManagerConnection . managerConnection . getState ( ) == ManagerConnectionState . CONNECTED ) ) { final org . asteriskjava . manager . action . ManagerAction ajAction = action . getAJAction ( ) ; org . asteriskjava . manager . response . ManagerResponse response = CoherentManagerConnection . managerConnection . sendAction ( ajAction , timeout ) ; ManagerResponse convertedResponse = null ; // UserEventActions always return a null if ( response != null ) convertedResponse = CoherentEventFactory . build ( response ) ; if ( ( convertedResponse != null ) && ( convertedResponse . getResponse ( ) . compareToIgnoreCase ( "Error" ) == 0 ) ) //$NON-NLS-1$ { CoherentManagerConnection . logger . warn ( "Action '" + ajAction + "' failed, Response: " //$NON-NLS-1$ //$NON-NLS-2$ + convertedResponse . getResponse ( ) + " Message: " + convertedResponse . getMessage ( ) ) ; //$NON-NLS-1$ } return convertedResponse ; } throw new IllegalStateException ( "not connected." ) ; //$NON-NLS-1$ }
Sends an Asterisk action and waits for a ManagerRespose .