Example #1
0
  @Override
  public synchronized void redirect(final Endpoint o, final Map<String, String> headers)
      throws SignalException {
    checkState();
    _redirected = true;
    setSIPCallState(SIPCall.State.REDIRECTED);

    terminate(CallCompleteEvent.Cause.REDIRECT, null, headers);

    if (o instanceof SIPEndpoint) {
      final SipServletResponse res =
          _invite.createResponse(SipServletResponse.SC_MOVED_TEMPORARILY);
      res.setHeader("Contact", ((SIPEndpoint) o).getURI().toString());
      SIPHelper.addHeaders(res, headers);
      try {
        res.send();
      } catch (final IOException e) {
        throw new SignalException(e);
      }
    } else {
      throw new IllegalArgumentException("Unable to redirect the call to a non-SIP participant.");
    }
  }