public Exception sendAndWaitForResponse ( TopLevelStreamElement request ) throws NoResponseException , NotConnectedException , InterruptedException { assert ( state == State . Initial ) ; connectionLock . lock ( ) ; try { if ( request != null ) { if ( request instanceof Stanza ) { connection . sendStanza ( ( Stanza ) request ) ; } else if ( request instanceof Nonza ) { connection . sendNonza ( ( Nonza ) request ) ; } else { throw new IllegalStateException ( "Unsupported element type" ) ; } state = State . RequestSent ; } waitForConditionOrTimeout ( ) ; } finally { connectionLock . unlock ( ) ; } return checkForResponse ( ) ; }
Send the given top level stream element and wait for a response .