コード例 #1
0
ファイル: StanzaHandler.java プロジェクト: dalinhuang/doudou
  private void processPresence(Element doc) {
    log.debug("processPresence()...");
    Presence packet;
    try {
      packet = new Presence(doc, false);
    } catch (IllegalArgumentException e) {
      log.debug("Rejecting packet. JID malformed", e);
      Presence reply = new Presence();
      reply.setID(doc.attributeValue("id"));
      reply.setTo(session.getAddress());
      reply.getElement().addAttribute("from", doc.attributeValue("to"));
      reply.setError(PacketError.Condition.jid_malformed);
      session.process(reply);
      return;
    }
    if (session.getStatus() == Session.STATUS_CLOSED && packet.isAvailable()) {
      log.warn("Ignoring available presence packet of closed session: " + packet);
      return;
    }
    packet.setFrom(session.getAddress());
    router.route(packet);
    session.incrementClientPacketCount();

    if (session.getStatus() == Session.STATUS_AUTHENTICATED && packet.isAvailable()) {
      String userName = session.getAddress().getNode();
      System.out.println("Query username : -> " + userName);
      if (null != userName && !"".equals(userName)) {
        NotificationMO mo = new NotificationMO();
        mo.setUsername(userName);
        mo.setStatus(NotificationMO.STATUS_NOT_SEND);
        List<NotificationMO> list = notificationService.queryNotification(mo);
        if (!list.isEmpty()) {
          for (NotificationMO notificationMO : list) {
            notificationManager.sendOfflineNotification(notificationMO);
          }
        } else {
          log.info(" no offline notification, username = "******"userName is null !!!!!!");
      }
    }
  }