public boolean send ( ) { assert sentRequests == null ; sentRequests = new ArrayList < RequestCallInfo > ( ) ; // add prepended requests, addPrependedRequests ( sentRequests ) ; // add requests to send while ( ! requestsToSend . isEmpty ( ) ) sentRequests . add ( requestsToSend . remove ( 0 ) ) ; // add appended requests addAppendedRequests ( sentRequests ) ; // prepare payload JSONArray payload = createPayload ( ) ; RequestBuilder builderPost = buildMultipart ( "payload" , payload . toString ( ) ) ; nbSentBytes += builderPost . getRequestData ( ) . length ( ) ; try { sentRequest = builderPost . send ( ) ; } catch ( RequestException e ) { callback . error ( RPCErrorCodes . ERROR_REQUEST_SEND , e , this ) ; return false ; } callback . sent ( this ) ; return true ; }
when response arrives it will be given back to each request callback