private void startListener() { try { if (scn != null) scn.close(); // <i><b>listen to requests on port 5060</b></i> scn = (SipConnectionNotifier) Connector.open("sip:5080"); scn.setListener(this); } catch (IOException ex) { // <i><b>handle IOException</b></i> } }
private void startSession() { SipClientConnection scc = null; try { // <i><b>start a listener for incoming requests</b></i> startListener(); // <i><b>open SIP connection with remote user</b></i> scc = (SipClientConnection) Connector.open(address.getString()); scc.setListener(this); // <i><b>initialize INVITE request</b></i> scc.initRequest("INVITE", scn); scc.setHeader("Content-Length", "" + sdp.length()); scc.setHeader("Content-Type", "application/sdp"); OutputStream os = scc.openContentOutputStream(); os.write(sdp.getBytes()); os.close(); // <i><b>close and send</b></i> str = new StringItem("Inviting... ", scc.getHeader("To")); form.append(str); } catch (Exception ex) { ex.printStackTrace(); // <i><b>handle IOException</b></i> } }