Пример #1
0
  public boolean sendRegister(final SipRequestState state, final SipProfile sipProfile) {

    SipRequest sipRequest = createSipRequest(SipRequestVerb.REGISTER, state, sipProfile, null);

    if (null != stateMachine
        && stateMachine.canRequestBeSent(SipRequestVerb.REGISTER, sipRequest.getRequest())) {
      sipConnection.setCurrentCallId(sipRequest.getCallIdHeader());
      sendRequest(SipRequestVerb.REGISTER, sipRequest.getRequest());
      return true;
    }
    return false;
  }
Пример #2
0
  public boolean sendInvite(
      final SipRequestState state, final SipProfile sipProfile, final SipContact sipContact) {
    SipRequest sipRequest = createSipRequest(SipRequestVerb.INVITE, state, sipProfile, sipContact);

    if (null != stateMachine
        && stateMachine.canRequestBeSent(SipRequestVerb.INVITE, sipRequest.getRequest())) {
      sipConnection.setCurrentCallId(sipRequest.getCallIdHeader());
      sendRequest(SipRequestVerb.INVITE, sipRequest.getRequest());
      return true;
    }
    return false;
  }
Пример #3
0
  private SipRequest createSipRequest(
      final SipRequestVerb sipRequestVerb,
      final SipRequestState state,
      final SipProfile sipProfile,
      final SipContact sipContact,
      final String textMessage) {

    // On REGISTER method, the sip contact must be the same as sip
    // profile sender.
    final SipContact newSipContact = (null == sipContact ? new SipContact(sipProfile) : sipContact);

    SipRequest sipRequest = null;
    try {
      sipRequest =
          new SipRequest(
              state,
              sipProfile,
              newSipContact,
              addressFactory,
              headerFactory,
              messageFactory,
              sipConnection.getProvider(),
              sipRequestVerbToRequestMethod(sipRequestVerb),
              sipConnection.getCallSequence(),
              70,
              300,
              textMessage);

      // update current CallId header of sipConnection
      sipConnection.setCurrentCallId(sipRequest.getCallIdHeader());
    } catch (ParseException | InvalidArgumentException | SipException | SdpException e) {
      e.printStackTrace();
    }

    return sipRequest;
  }