public void receiveMsrpSend(String txId,Hashtable<String,String> headers,int flag,byte[] data,long totalSize) throws PayloadException, NetworkException, ContactManagerException {
  mIsEstablished=true;
  if (sLogger.isActivated()) {
    sLogger.debug("SEND request received (flag=" + flag + ", transaction="+ txId+ ", totalSize="+ totalSize+ ")");
  }
  String msgId=headers.get(MsrpConstants.HEADER_MESSAGE_ID);
  boolean failureReportNeeded=true;
  String failureHeader=headers.get(MsrpConstants.HEADER_FAILURE_REPORT);
  if ((failureHeader != null) && failureHeader.equalsIgnoreCase("no")) {
    failureReportNeeded=false;
  }
  if (failureReportNeeded) {
    sendMsrpResponse(MsrpConstants.STATUS_200_OK,txId,headers);
  }
  if (data == null) {
    if (sLogger.isActivated()) {
      sLogger.debug("Empty chunk");
    }
    return;
  }
  mReceivedChunks.addChunk(data);
  if (flag == MsrpConstants.FLAG_LAST_CHUNK) {
    if (sLogger.isActivated()) {
      sLogger.info("Transfer terminated");
    }
    byte[] dataContent=mReceivedChunks.getReceivedData();
    mReceivedChunks.resetCache();
    String contentTypeHeader=headers.get(MsrpConstants.HEADER_CONTENT_TYPE);
    mMsrpEventListener.receiveMsrpData(msgId,dataContent,contentTypeHeader);
    boolean successReportNeeded=false;
    String reportHeader=headers.get(MsrpConstants.HEADER_SUCCESS_REPORT);
    if ((reportHeader != null) && reportHeader.equalsIgnoreCase("yes")) {
      successReportNeeded=true;
    }
    if (successReportNeeded) {
      sendMsrpReportRequest(txId,headers,dataContent.length,totalSize);
    }
  }
 else   if (flag == MsrpConstants.FLAG_ABORT_CHUNK) {
    if (sLogger.isActivated()) {
      sLogger.info("Transfer aborted");
    }
    mMsrpEventListener.msrpTransferAborted();
  }
 else   if (flag == MsrpConstants.FLAG_MORE_CHUNK) {
    if (sLogger.isActivated()) {
      sLogger.debug("Transfer in progress...");
    }
    byte[] dataContent=mReceivedChunks.getReceivedData();
    boolean resetCache=mMsrpEventListener.msrpTransferProgress(mReceivedChunks.getCurrentSize(),totalSize,dataContent);
    if (resetCache) {
      mReceivedChunks.resetCache();
    }
  }
}

public void receiveMsrpSend ( String txId , Hashtable < String , String > headers , int flag , byte [ ] data , long totalSize ) throws PayloadException , NetworkException , ContactManagerException { mIsEstablished = true ; if ( sLogger . isActivated ( ) ) { sLogger . debug ( "SEND request received (flag=" + flag + ", transaction=" + txId + ", totalSize=" + totalSize + ")" ) ; } String msgId = headers . get ( MsrpConstants . HEADER_MESSAGE_ID ) ; boolean failureReportNeeded = true ; String failureHeader = headers . get ( MsrpConstants . HEADER_FAILURE_REPORT ) ; if ( ( failureHeader != null ) && failureHeader . equalsIgnoreCase ( "no" ) ) { failureReportNeeded = false ; } if ( failureReportNeeded ) { sendMsrpResponse ( MsrpConstants . STATUS_200_OK , txId , headers ) ; } if ( data == null ) { if ( sLogger . isActivated ( ) ) { sLogger . debug ( "Empty chunk" ) ; } return ; } mReceivedChunks . addChunk ( data ) ; if ( flag == MsrpConstants . FLAG_LAST_CHUNK ) { if ( sLogger . isActivated ( ) ) { sLogger . info ( "Transfer terminated" ) ; } byte [ ] dataContent = mReceivedChunks . getReceivedData ( ) ; mReceivedChunks . resetCache ( ) ; String contentTypeHeader = headers . get ( MsrpConstants . HEADER_CONTENT_TYPE ) ; mMsrpEventListener . receiveMsrpData ( msgId , dataContent , contentTypeHeader ) ; boolean successReportNeeded = false ; String reportHeader = headers . get ( MsrpConstants . HEADER_SUCCESS_REPORT ) ; if ( ( reportHeader != null ) && reportHeader . equalsIgnoreCase ( "yes" ) ) { successReportNeeded = true ; } if ( successReportNeeded ) { sendMsrpReportRequest ( txId , headers , dataContent . length , totalSize ) ; } } else if ( flag == MsrpConstants . FLAG_ABORT_CHUNK ) { if ( sLogger . isActivated ( ) ) { sLogger . info ( "Transfer aborted" ) ; } mMsrpEventListener . msrpTransferAborted ( ) ; } else if ( flag == MsrpConstants . FLAG_MORE_CHUNK ) { if ( sLogger . isActivated ( ) ) { sLogger . debug ( "Transfer in progress..." ) ; } byte [ ] dataContent = mReceivedChunks . getReceivedData ( ) ; boolean resetCache = mMsrpEventListener . msrpTransferProgress ( mReceivedChunks . getCurrentSize ( ) , totalSize , dataContent ) ; if ( resetCache ) { mReceivedChunks . resetCache ( ) ; } } }
receive msrp send request
