示例#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
  public boolean sendMessage(
      final SipRequestState state,
      final SipProfile sipProfile,
      final SipContact sipContact,
      final String textMessage) {

    SipRequest sipRequest =
        createSipRequest(SipRequestVerb.MESSAGE, state, sipProfile, sipContact, textMessage);

    if (null != stateMachine
        && stateMachine.canRequestBeSent(SipRequestVerb.MESSAGE, sipRequest.getRequest())) {
      sendRequest(SipRequestVerb.MESSAGE, sipRequest.getRequest());
      return true;
    }
    return false;
  }
示例#4
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;
  }