/** * * @param req * @throws IOException */ private void notImplemented(SipServletRequest req) throws IOException { SipServletResponse resp = req.createResponse(501, "Request not implemented"); resp.send(); } }
/** * * @param req * @throws IOException */ private void notHandled(SipServletRequest req) throws IOException { SipServletResponse resp = req.createResponse(500, "Request not handled by app"); resp.send(); }
private void fail(int code) { final SipServletResponse fail = initialInvite.createResponse(code); try { fail.send(); } catch(final IOException exception) { logger.error(exception); } cleanup(); setState(FAILED); }
public synchronized void bye(final SipServletRequest request) throws IOException { final List<State> possibleStates = new ArrayList<State>(); possibleStates.add(QUEUED); possibleStates.add(RINGING); possibleStates.add(IN_PROGRESS); assertState(possibleStates); final SipServletResponse ok = request.createResponse(SipServletResponse.SC_OK); try { ok.send(); } finally { cleanup(); setState(COMPLETED); dateEnded = DateTime.now(); fireStatusChanged(); } }
public synchronized void cancel(final SipServletRequest request) throws IOException { final List<State> possibleStates = new ArrayList<State>(); possibleStates.add(QUEUED); possibleStates.add(RINGING); possibleStates.add(TRYING); assertState(possibleStates); final SipServletResponse ok = request.createResponse(SipServletResponse.SC_OK); try { ok.send(); } finally { cleanup(); setState(CANCELLED); fireStatusChanged(); } }
@Override public synchronized void reject() { assertState(RINGING); final SipServletResponse busy = initialInvite.createResponse(SipServletResponse.SC_BUSY_HERE); try { busy.send(); } catch(final IOException exception) { cleanup(); setState(FAILED); fireStatusChanged(); logger.error(exception); } }
private synchronized void alert(final SipServletRequest request) throws CallException { assertState(TRYING); final SipServletResponse ringing = request.createResponse(SipServletResponse.SC_RINGING); try { ringing.send(); setState(RINGING); fireStatusChanged(); } catch(final Exception exception) { cleanup(); setState(FAILED); fireStatusChanged(); logger.error(exception); throw new CallException(exception); } }
static void authenticate(final SipServletRequest request, String realm) throws IOException { final SipServletResponse response = request.createResponse(SC_PROXY_AUTHENTICATION_REQUIRED); final String nonce = nonce(); String algorithm = RestcommConfiguration.getInstance().getMain().getClientAlgorithm(); String qop = RestcommConfiguration.getInstance().getMain().getClientQOP(); final String header = header(nonce, realm, "Digest", algorithm, qop); response.addHeader("Proxy-Authenticate", header); response.send(); }
public synchronized void trying(final SipServletRequest request) throws CallException { assertState(IDLE); final SipServletResponse trying = request.createResponse(SipServletResponse.SC_TRYING); try{ trying.send(); final SipServletResponse response = request.createResponse(SipServletResponse.SC_BAD_REQUEST); response.send(); throw new CallException("The remote client did not send an SDP offer with their INVITE request.");
@Override public synchronized void answer() throws CallException { assertState(RINGING); try { // Establish the media path way. relayOutboundConnection = session.createConnection(relayEndpoint); relayOutboundConnection.addObserver(this); relayOutboundConnection.connect(ConnectionMode.SendRecv); block(6, RINGING); // Send the response back to the caller. final byte[] answer = patchMedia(server.getExternalAddress(), userAgentConnection.getLocalDescriptor().toString().getBytes()); final SipServletResponse ok = initialInvite.createResponse(SipServletResponse.SC_OK); ok.setContent(answer, "application/sdp"); ok.send(); } catch(final Exception exception) { fail(SipServletResponse.SC_SERVER_INTERNAL_ERROR); fireStatusChanged(); logger.error(exception); throw new CallException(exception); } }
SipServletResponse clonedResponse = linkedRequest.createResponse(response.getStatus()); SipURI originalURI = null; try {
request.createResponse(100).send();
request.createResponse(100).send();