コード例 #1
0
  public void signOut() {
    try {
      sipRC.register(this.getLocalURI(), true);
    } catch (Exception e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    Element[] elms = new Element[3];

    elms[0] = new Element(MessageCons.IM_TYPE, MessageCons.GATEWAY, Message.JXTA_NAME_SPACE);
    elms[1] = new Element(MessageCons.FROM_HEADER, this.getLocalURI(), Message.JXTA_NAME_SPACE);
    elms[2] =
        new Element(
            MessageCons.IM_STATUS,
            Integer.toString(MessageCons.IM_STATUS_OFFLINE),
            Message.JXTA_NAME_SPACE);

    try {
      groupsvc.send(impipe, new Message(elms));
    } catch (IOException e) {
      e.printStackTrace();
      //            LOG.error("could not subscribe, no other IM running");
      //            throw new IMException("could not subscribe, no other IM running");
    }
  }
コード例 #2
0
  private void sendGatewayMessage() {
    Element[] elms = new Element[3];

    logger.debug("Sending GATEWAY messgae to indicate presence ...");
    elms[0] = new Element(MessageCons.IM_TYPE, MessageCons.GATEWAY, Message.JXTA_NAME_SPACE);
    elms[1] = new Element(MessageCons.FROM_HEADER, this.getLocalURI(), Message.JXTA_NAME_SPACE);
    elms[2] =
        new Element(
            MessageCons.IM_STATUS,
            Integer.toString(MessageCons.IM_STATUS_ONLINE),
            Message.JXTA_NAME_SPACE);

    try {
      groupsvc.send(impipe, new Message(elms));
    } catch (IOException e) {
      e.printStackTrace();
      //            LOG.error("could not subscribe, no other IM running");
      //            throw new IMException("could not subscribe, no other IM running");
    }
  }
コード例 #3
0
  /* (non-Javadoc)
   * @see ch.ethz.jadabs.im.sip.IMUserAgent#process(java.lang.String, java.lang.String)
   */
  public void processMessageRequest(String fromSipAddress, String toSipAddress, String message) {
    if (impipe == null) logger.info("could not send message, no pipe");

    Element[] elms = new Element[4];

    String toaddress = IMUtilities.getUsernameFromURI(toSipAddress);
    String fromaddress = IMUtilities.getUsernameFromURI(fromSipAddress);

    elms[0] = new Element(MessageCons.IM_TYPE, MessageCons.MESSAGE, Message.JXTA_NAME_SPACE);
    elms[1] = new Element(MessageCons.TO_HEADER, toaddress, Message.JXTA_NAME_SPACE);
    elms[2] = new Element(MessageCons.FROM_HEADER, fromaddress, Message.JXTA_NAME_SPACE);
    elms[3] = new Element(MessageCons.MESSAGE_VALUE, message, Message.JXTA_NAME_SPACE);

    try {
      logger.debug("Sending message: " + message + " to: " + toaddress);
      groupsvc.send(impipe, new Message(elms));
    } catch (IOException e) {
      e.printStackTrace();
      logger.info("could not send message", e);
    }
  }