/** * Handle 200 0K response * * @param resp 200 OK response */ public void handle200OK(SipResponse resp) { try { // 200 OK received if (logger.isActivated()) { logger.info("200 OK response received"); } // The signalisation is established getDialogPath().sigEstablished(); // Set the remote tag getDialogPath().setRemoteTag(resp.getToTag()); // Set the target getDialogPath().setTarget(resp.getContactURI()); // Set the route path with the Record-Route header Vector<String> newRoute = SipUtils.routeProcessing(resp, true); getDialogPath().setRoute(newRoute); // Set the remote SDP part getDialogPath().setRemoteContent(resp.getContent()); // Parse the remote SDP part SdpParser parser = new SdpParser(getDialogPath().getRemoteContent().getBytes()); Vector<MediaDescription> media = parser.getMediaDescriptions(); MediaDescription mediaDesc = media.elementAt(0); MediaAttribute attr = mediaDesc.getMediaAttribute("path"); String remoteMsrpPath = attr.getValue(); String remoteHost = SdpUtils.extractRemoteHost(parser.sessionDescription.connectionInfo); int remotePort = mediaDesc.port; // Send ACK request if (logger.isActivated()) { logger.info("Send ACK"); } getImsService().getImsModule().getSipManager().sendSipAck(getDialogPath()); // The session is established getDialogPath().sessionEstablished(); // Create the MSRP client session MsrpSession session = msrpMgr.createMsrpClientSession(remoteHost, remotePort, remoteMsrpPath, this); session.setFailureReportOption(false); session.setSuccessReportOption(true); // Open the MSRP session msrpMgr.openMsrpSession(); // Start session timer if (getSessionTimerManager().isSessionTimerActivated(resp)) { getSessionTimerManager() .start(resp.getSessionTimerRefresher(), resp.getSessionTimerExpire()); } // Notify listeners for (int i = 0; i < getListeners().size(); i++) { getListeners().get(i).handleSessionStarted(); } // Start sending data chunks byte[] data = getContent().getData(); InputStream stream; if (data == null) { // Load data from URL stream = FileFactory.getFactory().openFileInputStream(getContent().getUrl()); } else { // Load data from memory stream = new ByteArrayInputStream(data); } msrpMgr.sendChunks( stream, ChatUtils.generateMessageId(), getContent().getEncoding(), getContent().getSize()); } catch (Exception e) { if (logger.isActivated()) { logger.error("Session initiation has failed", e); } // Unexpected error handleError(new FileSharingError(FileSharingError.UNEXPECTED_EXCEPTION, e.getMessage())); } }
/** * Handle 200 0K response * * @param resp 200 OK response */ public void handle200OK(SipResponse resp) { try { // 200 OK received if (logger.isActivated()) { logger.info("200 OK response received"); } // The signaling is established getDialogPath().sigEstablished(); // Set the remote tag getDialogPath().setRemoteTag(resp.getToTag()); // Set the target getDialogPath().setTarget(resp.getContactURI()); // Set the route path with the Record-Route header Vector<String> newRoute = SipUtils.routeProcessing(resp, true); getDialogPath().setRoute(newRoute); // Set the remote SDP part getDialogPath().setRemoteContent(resp.getContent()); Capabilities capabilities = CapabilityUtils.extractCapabilities(resp); if (capabilities != null && this instanceof GroupChatSession) { ((GroupChatSession) this).setMsrpFtSupport(capabilities.isFileTransferSupported()); } // Set the remote SIP instance ID ContactHeader remoteContactHeader = (ContactHeader) resp.getHeader(ContactHeader.NAME); if (remoteContactHeader != null) { getDialogPath() .setRemoteSipInstance(remoteContactHeader.getParameter(SipUtils.SIP_INSTANCE_PARAM)); } // Prepare Media Session prepareMediaSession(); // Send ACK request if (logger.isActivated()) { logger.info("Send ACK"); } getImsService().getImsModule().getSipManager().sendSipAck(getDialogPath()); // The session is established getDialogPath().sessionEstablished(); // Start Media Session startMediaSession(); // Notify listeners for (int i = 0; i < getListeners().size(); i++) { getListeners().get(i).handleSessionStarted(); } // Start session timer if (getSessionTimerManager().isSessionTimerActivated(resp)) { getSessionTimerManager() .start(resp.getSessionTimerRefresher(), resp.getSessionTimerExpire()); } } catch (Exception e) { // Unexpected error if (logger.isActivated()) { logger.error("Session initiation has failed", e); } handleError(new ImsServiceError(ImsServiceError.UNEXPECTED_EXCEPTION, e.getMessage())); } }