示例#1
0
  /**
   * Starts a new InviteTransactionClient and initializes the dialog state information.
   *
   * @param callee the callee url (and display name)
   * @param caller the caller url (and display name)
   * @param contact the contact url OR the contact username
   * @param session_descriptor SDP body
   * @param icsi the ICSI for this session
   */
  public void invite(
      String callee,
      String caller,
      String contact,
      String session_descriptor,
      String icsi) { // modified by mandrajg
    printLog("inside invite(callee,caller,contact,sdp)", LogLevel.MEDIUM);
    if (!statusIs(D_INIT)) return;
    // else
    NameAddress to_url = new NameAddress(callee);
    NameAddress from_url = new NameAddress(caller);
    SipURL request_uri = to_url.getAddress();

    NameAddress contact_url = null;
    if (contact != null) {
      if (contact.indexOf("sip:") >= 0) contact_url = new NameAddress(contact);
      else
        contact_url =
            new NameAddress(
                new SipURL(contact, sip_provider.getViaAddress(), sip_provider.getPort()));
    } else contact_url = from_url;

    Message invite =
        MessageFactory.createInviteRequest(
            sip_provider,
            request_uri,
            to_url,
            from_url,
            contact_url,
            session_descriptor,
            icsi); // modified by mandrajg
    // do invite
    invite(invite);
  }
示例#2
0
 /** Sends a new message. */
 public void send(
     String recipient, String subject, String content_type, String content, String displayname) {
   NameAddress to_url = new NameAddress(recipient);
   NameAddress from_url = new NameAddress(user_profile.from_url);
   from_url.setDisplayName(displayname);
   MessageFactory msgf = new MessageFactory();
   Message req =
       msgf.createMessageRequest(sip_provider, to_url, from_url, subject, content_type, content);
   TransactionClient t = new TransactionClient(sip_provider, req, this);
   t.request();
 }
示例#3
0
  /** When a new Message is received by the SipProvider. */
  public void onReceivedMessage(SipProvider provider, Message msg) {
    // printLog("onReceivedMessage()", LogLevel.MEDIUM);
    if (statusIs(D_TERMINATED)) {
      printLog("subscription already terminated: message discarded", LogLevel.MEDIUM);
      return;
    }
    // else
    if (msg.isRequest() && msg.isSubscribe()) {
      if (statusIs(NotifierDialog.D_WAITING)) { // the first SUBSCRIBE
        // request
        changeStatus(D_SUBSCRIBED);
        sip_provider.removeSipProviderListener(new MethodIdentifier(SipMethods.SUBSCRIBE));
      }
      subscribe_req = msg;
      NameAddress target = msg.getToHeader().getNameAddress();
      NameAddress subscriber = msg.getFromHeader().getNameAddress();
      EventHeader eh = msg.getEventHeader();
      if (eh != null) {
        event = eh.getEvent();
        id = eh.getId();
      }
      // ==> jinsub for presence server
      if (event.endsWith("presence")) {
        notifyEvent = target.toString();
      }
      //
      update(UAS, msg);
      // System.out.println("����� ��¿��?");
      // subscribe_transaction = new TransactionServer(sip_provider, msg, null);
      if (listener != null)
        // Here is going to add vector_key
        listener.onDlgSubscribe(this, target, subscriber, event, id, msg);

    } else if (msg.isRequest() && msg.isPublish()) {
      // ==> jinsub for presence server
      NameAddress target = msg.getToHeader().getNameAddress();
      NameAddress publisher = msg.getFromHeader().getNameAddress();
      EventHeader eh = msg.getEventHeader();
      if (eh.getEvent().endsWith(event) && target.toString().endsWith(notifyEvent)) {
        // System.out.println("����� ��¿��2?");
        // publish_transaction = new TransactionServer(sip_provider, msg, null);
        if (listener != null) listener.onDlgPublish(this, target, publisher, event, id, msg);
      }
      //
    } else {
      printLog("message is not a SUBSCRIBE: message discarded", LogLevel.HIGH);
    }
  }