/** Handle incoming response here */ public void notifyResponse(SipClientConnection scc) { int statusCode = 0; boolean received = false; try { scc.receive(0); // <i><b>fetch resent response</b></i> statusCode = scc.getStatusCode(); str = new StringItem("Response: ", statusCode + " " + scc.getReasonPhrase()); form.append(str); if (statusCode < 200) { dialog = scc.getDialog(); form.append("Early-Dialog state: " + dialog.getState()); } if (statusCode == 200) { String contentType = scc.getHeader("Content-Type"); String contentLength = scc.getHeader("Content-Length"); int length = Integer.parseInt(contentLength); if (contentType.equals("application/sdp")) { // // <i><b>handle SDP here</b></i> // } dialog = scc.getDialog(); // <i><b>save dialog info</b></i> form.append("Dialog state: " + dialog.getState()); scc.initAck(); // <i><b>initialize and send ACK</b></i> scc.send(); str = new StringItem("Session established: ", scc.getHeader("Call-ID")); form.append(str); scc.close(); } else if (statusCode >= 300) { str = new StringItem("Session failed: ", scc.getHeader("Call-ID")); form.append(str); form.removeCommand(byeCmd); form.addCommand(restartCmd); scc.close(); } } catch (IOException ioe) { // <i><b>handle e.g. transaction timeout here</b></i> str = new StringItem("No answer: ", ioe.getMessage()); form.append(str); form.removeCommand(byeCmd); form.addCommand(restartCmd); } }