• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java OfflineMessage类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.jivesoftware.openfire.OfflineMessage的典型用法代码示例。如果您正苦于以下问题:Java OfflineMessage类的具体用法?Java OfflineMessage怎么用?Java OfflineMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

OfflineMessage类属于org.jivesoftware.openfire包,在下文中一共展示了OfflineMessage类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getItems

点赞 2

import org.jivesoftware.openfire.OfflineMessage; //导入依赖的package包/类
@Override
public Iterator<DiscoItem> getItems(String name, String node, JID senderJID) {
    // Mark that offline messages shouldn't be sent when the user becomes available
    stopOfflineFlooding(senderJID);
    List<DiscoItem> answer = new ArrayList<>();
    for (OfflineMessage offlineMessage : messageStore.getMessages(senderJID.getNode(), false)) {
        answer.add(new DiscoItem(senderJID.asBareJID(), offlineMessage.getFrom().toString(),
                XMPPDateTimeFormat.format(offlineMessage.getCreationDate()), null));
    }

    return answer.iterator();
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:13,
代码来源:IQOfflineMessagesHandler.java

示例2: initSession

点赞 2

import org.jivesoftware.openfire.OfflineMessage; //导入依赖的package包/类
/**
 * A session that has transitioned to available status must be initialized.
 * This includes:
 * <ul>
 * <li>Sending all offline presence subscription requests</li>
 * <li>Sending offline messages</li>
 * </ul>
 *
 * @param session The session being updated
 * @throws UserNotFoundException If the user being updated does not exist
 */
private void initSession(ClientSession session) throws UserNotFoundException {

    // Only user sessions need to be authenticated
    if (userManager.isRegisteredUser(session.getAddress().getNode())) {
        String username = session.getAddress().getNode();

        // Send pending subscription requests to user if roster service is enabled
        if (RosterManager.isRosterServiceEnabled()) {
            Roster roster = rosterManager.getRoster(username);
            for (RosterItem item : roster.getRosterItems()) {
                if (item.getRecvStatus() == RosterItem.RECV_SUBSCRIBE) {
                    session.process(createSubscribePresence(item.getJid(),
                            session.getAddress().asBareJID(), true));
                } else if (item.getRecvStatus() == RosterItem.RECV_UNSUBSCRIBE) {
                    session.process(createSubscribePresence(item.getJid(),
                            session.getAddress().asBareJID(), false));
                }
                if (item.getSubStatus() == RosterItem.SUB_TO
                        || item.getSubStatus() == RosterItem.SUB_BOTH) {
                    presenceManager.probePresence(session.getAddress(), item.getJid());
                }
            }
        }
        if (session.canFloodOfflineMessages()) {
            // deliver offline messages if any
            Collection<OfflineMessage> messages = messageStore.getMessages(username, true);
            for (Message message : messages) {
                session.process(message);
            }
        }
    }
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:44,
代码来源:PresenceUpdateHandler.java

示例3: exportOfflineMessages

点赞 2

import org.jivesoftware.openfire.OfflineMessage; //导入依赖的package包/类
/**
 * Adding offline messages, if there are some.
 * 
 * @param hostname
 *            host name
 * @param userElement
 *            DOM element
 * @param userName
 *            user name
 */
@SuppressWarnings("unchecked")
private void exportOfflineMessages(String hostname, Element userElement,
    String userName) {
  Collection<OfflineMessage> offlineMessages = offlineMessagesStore
      .getMessages(userName, false);

  if (!offlineMessages.isEmpty()) {
    Element offlineElement = userElement.addElement(OFFLINE_MESSAGES_ELEMENT_NAME);

    for (OfflineMessage offMessage : offlineMessages) {
      
      Element messageElement = offlineElement.addElement(new QName(MESSAGE_ELEMENT_NAME, JABBER_MSG_NS));
      for ( Object att : offMessage.getElement().attributes() ) {
        Attribute attribute = (Attribute) att;
        messageElement.addAttribute(attribute.getQName(),attribute.getValue());
      }
      
      for (Iterator<Element> iterator = offMessage.getElement().elementIterator(); iterator
          .hasNext();) {
        Element element = iterator.next();
        messageElement.add(element.createCopy(new QName(element.getName(), (element.getNamespace() == Namespace.NO_NAMESPACE ? JABBER_MSG_NS : element.getNamespace()))));
        
      }
      
      /**
       * Adding delay element
       */
      Element delayElement = messageElement.addElement("delay", "urn:xmpp:delay");
      delayElement.addAttribute(FROM_NAME, hostname);
      delayElement.addAttribute("stamp", XMPPDateTimeFormat.format(offMessage.getCreationDate()));
      delayElement.addText("Offline Storage");
    }

  }

}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:47,
代码来源:Xep227Exporter.java

示例4: importOffLineMessages

点赞 2

import org.jivesoftware.openfire.OfflineMessage; //导入依赖的package包/类
/**
 * @param userElement
 * @param offlineMessages
 */
@SuppressWarnings("unchecked")
private void importOffLineMessages(Element userElement, List<OfflineMessage> offlineMessages) {
  Log.debug("importOffLineMessages");
  // TODO Auto-generated method stub

  Iterator<Element> messageIter = userElement.elementIterator(MESSAGE_ELEMENT_NAME);

  while (messageIter.hasNext()) {
    Element msgElement = messageIter.next();

    String creationDateStr = null;
    if (msgElement.element(DELAY_ELEMENT_NAME) != null) {
      creationDateStr = msgElement.element(DELAY_ELEMENT_NAME).attributeValue(STAMP_NAME);
    }

    Date creationDate = null;
    try {
      if (creationDateStr != null) {
        creationDate = dateformater.parse(creationDateStr);
      }
    } catch (ParseException e) {
      Log.warn("Date not parsable:" + e.getLocalizedMessage());
    }

    offlineMessages.add(new OfflineMessage(creationDate, msgElement));
  }
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:32,
代码来源:Xep227Exporter.java

示例5: getMessages

点赞 2

import org.jivesoftware.openfire.OfflineMessage; //导入依赖的package包/类
@Override
public Collection<OfflineMessage> getMessages(String username, boolean delete) {
  logger.finest("getMessages");
  Collection<OfflineMessage> offMsgs = new ArrayList<OfflineMessage>();
  Element element = new DOMElement("message");
  Date creationDate = new Date();
  OfflineMessage offmsg = new OfflineMessage(creationDate, element);
  offmsg.setFrom(new JID("[email protected]"));
  offmsg.setTo(new JID("[email protected]"));
  offmsg.setBody("text");
  offMsgs.add(offmsg);
  return offMsgs;
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:14,
代码来源:Xep227ExporterTest.java

示例6: sendOfflineMessage

点赞 2

import org.jivesoftware.openfire.OfflineMessage; //导入依赖的package包/类
private void sendOfflineMessage(JID receipient, OfflineMessage offlineMessage) {
    Element offlineInfo = offlineMessage.addChildElement("offline", NAMESPACE);
    synchronized (dateFormat) {
        offlineInfo.addElement("item").addAttribute("node",
                dateFormat.format(offlineMessage.getCreationDate()));
    }
    routingTable.routePacket(receipient, offlineMessage, true);
}
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:9,
代码来源:IQOfflineMessagesHandler.java

示例7: getItems

点赞 2

import org.jivesoftware.openfire.OfflineMessage; //导入依赖的package包/类
public Iterator<DiscoItem> getItems(String name, String node, JID senderJID) {
    // Mark that offline messages shouldn't be sent when the user becomes available
    stopOfflineFlooding(senderJID);
    List<DiscoItem> answer = new ArrayList<DiscoItem>();
    for (OfflineMessage offlineMessage : messageStore.getMessages(senderJID.getNode(), false)) {
        synchronized (dateFormat) {
            answer.add(new DiscoItem(new JID(senderJID.toBareJID()), offlineMessage.getFrom().toString(), dateFormat.format(offlineMessage.getCreationDate()), null));
        }
    }

    return answer.iterator();
}
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:13,
代码来源:IQOfflineMessagesHandler.java

示例8: initSession

点赞 2

import org.jivesoftware.openfire.OfflineMessage; //导入依赖的package包/类
/**
 * A session that has transitioned to available status must be initialized.
 * This includes:
 * <ul>
 * <li>Sending all offline presence subscription requests</li>
 * <li>Sending offline messages</li>
 * </ul>
 *
 * @param session The session being updated
 * @throws UserNotFoundException If the user being updated does not exist
 */
private void initSession(ClientSession session) throws UserNotFoundException {

    // Only user sessions need to be authenticated
    if (userManager.isRegisteredUser(session.getAddress().getNode())) {
        String username = session.getAddress().getNode();

        // Send pending subscription requests to user if roster service is enabled
        if (RosterManager.isRosterServiceEnabled()) {
            Roster roster = rosterManager.getRoster(username);
            for (RosterItem item : roster.getRosterItems()) {
                if (item.getRecvStatus() == RosterItem.RECV_SUBSCRIBE) {
                    session.process(createSubscribePresence(item.getJid(),
                            new JID(session.getAddress().toBareJID()), true));
                } else if (item.getRecvStatus() == RosterItem.RECV_UNSUBSCRIBE) {
                    session.process(createSubscribePresence(item.getJid(),
                            new JID(session.getAddress().toBareJID()), false));
                }
                if (item.getSubStatus() == RosterItem.SUB_TO
                        || item.getSubStatus() == RosterItem.SUB_BOTH) {
                    presenceManager.probePresence(session.getAddress(), item.getJid());
                }
            }
        }
        if (session.canFloodOfflineMessages()) {
            // deliver offline messages if any
            Collection<OfflineMessage> messages = messageStore.getMessages(username, true);
            for (Message message : messages) {
                session.process(message);
            }
        }
    }
}
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:44,
代码来源:PresenceUpdateHandler.java

示例9: getItems

点赞 2

import org.jivesoftware.openfire.OfflineMessage; //导入依赖的package包/类
public Iterator<DiscoItem> getItems(String name, String node, JID senderJID) {
    // Mark that offline messages shouldn't be sent when the user becomes available
    stopOfflineFlooding(senderJID);
    List<DiscoItem> answer = new ArrayList<DiscoItem>();
    for (OfflineMessage offlineMessage : messageStore.getMessages(senderJID.getNode(), false)) {
        answer.add(new DiscoItem(senderJID.asBareJID(), offlineMessage.getFrom().toString(),
                XMPPDateTimeFormat.format(offlineMessage.getCreationDate()), null));
    }

    return answer.iterator();
}
 

开发者ID:idwanglu2010,
项目名称:openfire,
代码行数:12,
代码来源:IQOfflineMessagesHandler.java

示例10: getItems

点赞 2

import org.jivesoftware.openfire.OfflineMessage; //导入依赖的package包/类
public Iterator<DiscoItem> getItems(String name, String node, JID senderJID) {
    // Mark that offline messages shouldn't be sent when the user becomes available
    stopOfflineFlooding(senderJID);
    List<DiscoItem> answer = new ArrayList<DiscoItem>();
    for (OfflineMessage offlineMessage : messageStore.getMessages(senderJID.getNode(), false)) {
        answer.add(new DiscoItem(new JID(senderJID.toBareJID()), offlineMessage.getFrom().toString(),
                XMPPDateTimeFormat.format(offlineMessage.getCreationDate()), null));
    }

    return answer.iterator();
}
 

开发者ID:surevine,
项目名称:openfire-bespoke,
代码行数:12,
代码来源:IQOfflineMessagesHandler.java

示例11: handleIQ

点赞 2

import org.jivesoftware.openfire.OfflineMessage; //导入依赖的package包/类
@Override
public IQ handleIQ(IQ packet) throws UnauthorizedException {
    IQ reply = IQ.createResultIQ(packet);
    Element offlineRequest = packet.getChildElement();

    JID from = packet.getFrom();
    if (offlineRequest.element("purge") != null) {
        // User requested to delete all offline messages
        messageStore.deleteMessages(from.getNode());
    }
    else if (offlineRequest.element("fetch") != null) {
        // Mark that offline messages shouldn't be sent when the user becomes available
        stopOfflineFlooding(from);
        // User requested to receive all offline messages
        for (OfflineMessage offlineMessage : messageStore.getMessages(from.getNode(), false)) {
            sendOfflineMessage(from, offlineMessage);
        }
    }
    else {
        for (Iterator it = offlineRequest.elementIterator("item"); it.hasNext();) {
            Element item = (Element) it.next();
            Date creationDate = null;
            try {
                creationDate = xmppDateTime.parseString(item.attributeValue("node"));
            } catch (ParseException e) {
                Log.error("Error parsing date", e);
            }
            if ("view".equals(item.attributeValue("action"))) {
                // User requested to receive specific message
                OfflineMessage offlineMsg = messageStore.getMessage(from.getNode(), creationDate);
                if (offlineMsg != null) {
                    sendOfflineMessage(from, offlineMsg);
                }
            }
            else if ("remove".equals(item.attributeValue("action"))) {
                // User requested to delete specific message
                if (messageStore.getMessage(from.getNode(), creationDate) != null) {
                    messageStore.deleteMessage(from.getNode(), creationDate);
                } else {
                    // If the requester is authorized but the node does not exist, the server MUST return a <item-not-found/> error.
                    reply.setError(PacketError.Condition.item_not_found);
                }
            }
        }
    }
    return reply;
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:48,
代码来源:IQOfflineMessagesHandler.java

示例12: sendOfflineMessage

点赞 2

import org.jivesoftware.openfire.OfflineMessage; //导入依赖的package包/类
private void sendOfflineMessage(JID receipient, OfflineMessage offlineMessage) {
    Element offlineInfo = offlineMessage.addChildElement("offline", NAMESPACE);
    offlineInfo.addElement("item").addAttribute("node",
            XMPPDateTimeFormat.format(offlineMessage.getCreationDate()));
    routingTable.routePacket(receipient, offlineMessage, true);
}
 

开发者ID:igniterealtime,
项目名称:Openfire,
代码行数:7,
代码来源:IQOfflineMessagesHandler.java

示例13: handleIQ

点赞 2

import org.jivesoftware.openfire.OfflineMessage; //导入依赖的package包/类
@Override
public IQ handleIQ(IQ packet) throws UnauthorizedException {
       IQ reply = IQ.createResultIQ(packet);
       Element offlineRequest = packet.getChildElement();

       JID from = packet.getFrom();
       if (offlineRequest.element("purge") != null) {
           // User requested to delete all offline messages
           messageStore.deleteMessages(from.getNode());
       }
       else if (offlineRequest.element("fetch") != null) {
           // Mark that offline messages shouldn't be sent when the user becomes available
           stopOfflineFlooding(from);
           // User requested to receive all offline messages
           for (OfflineMessage offlineMessage : messageStore.getMessages(from.getNode(), false)) {
               sendOfflineMessage(from, offlineMessage);
           }
       }
       else {
           for (Iterator it = offlineRequest.elementIterator("item"); it.hasNext();) {
               Element item = (Element) it.next();
               Date creationDate = null;
               synchronized (dateFormat) {
                   try {
                       creationDate = dateFormat.parse(item.attributeValue("node"));
                   }
                   catch (ParseException e) {
                       Log.error("Error parsing date", e);
                   }
               }
               if ("view".equals(item.attributeValue("action"))) {
                   // User requested to receive specific message
                   OfflineMessage offlineMsg = messageStore.getMessage(from.getNode(), creationDate);
                   if (offlineMsg != null) {
                       sendOfflineMessage(from, offlineMsg);
                   }
               }
               else if ("remove".equals(item.attributeValue("action"))) {
                   // User requested to delete specific message
                   messageStore.deleteMessage(from.getNode(), creationDate);
               }
           }
       }
       return reply;
   }
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:46,
代码来源:IQOfflineMessagesHandler.java

示例14: handleIQ

点赞 2

import org.jivesoftware.openfire.OfflineMessage; //导入依赖的package包/类
@Override
public IQ handleIQ(IQ packet) throws UnauthorizedException {
       IQ reply = IQ.createResultIQ(packet);
       Element offlineRequest = packet.getChildElement();

       JID from = packet.getFrom();
       if (offlineRequest.element("purge") != null) {
           // User requested to delete all offline messages
           messageStore.deleteMessages(from.getNode());
       }
       else if (offlineRequest.element("fetch") != null) {
           // Mark that offline messages shouldn't be sent when the user becomes available
           stopOfflineFlooding(from);
           // User requested to receive all offline messages
           for (OfflineMessage offlineMessage : messageStore.getMessages(from.getNode(), false)) {
               sendOfflineMessage(from, offlineMessage);
           }
       }
       else {
           for (Iterator it = offlineRequest.elementIterator("item"); it.hasNext();) {
               Element item = (Element) it.next();
               Date creationDate = null;
               try {
                   creationDate = xmppDateTime.parseString(item.attributeValue("node"));
               } catch (ParseException e) {
                   Log.error("Error parsing date", e);
               }
               if ("view".equals(item.attributeValue("action"))) {
                   // User requested to receive specific message
                   OfflineMessage offlineMsg = messageStore.getMessage(from.getNode(), creationDate);
                   if (offlineMsg != null) {
                       sendOfflineMessage(from, offlineMsg);
                   }
               }
               else if ("remove".equals(item.attributeValue("action"))) {
                   // User requested to delete specific message
                   if (messageStore.getMessage(from.getNode(), creationDate) != null) {
                       messageStore.deleteMessage(from.getNode(), creationDate);
                   } else {
                       // If the requester is authorized but the node does not exist, the server MUST return a <item-not-found/> error.
                       reply.setError(PacketError.Condition.item_not_found);
                   }
               }
           }
       }
       return reply;
   }
 

开发者ID:idwanglu2010,
项目名称:openfire,
代码行数:48,
代码来源:IQOfflineMessagesHandler.java

示例15: handleIQ

点赞 2

import org.jivesoftware.openfire.OfflineMessage; //导入依赖的package包/类
@Override
public IQ handleIQ(IQ packet) throws UnauthorizedException {
       IQ reply = IQ.createResultIQ(packet);
       Element offlineRequest = packet.getChildElement();

       JID from = packet.getFrom();
       if (offlineRequest.element("purge") != null) {
           // User requested to delete all offline messages
           messageStore.deleteMessages(from.getNode());
       }
       else if (offlineRequest.element("fetch") != null) {
           // Mark that offline messages shouldn't be sent when the user becomes available
           stopOfflineFlooding(from);
           // User requested to receive all offline messages
           for (OfflineMessage offlineMessage : messageStore.getMessages(from.getNode(), false)) {
               sendOfflineMessage(from, offlineMessage);
           }
       }
       else {
           for (Iterator it = offlineRequest.elementIterator("item"); it.hasNext();) {
               Element item = (Element) it.next();
               Date creationDate = null;
               try {
                   creationDate = xmppDateTime.parseString(item.attributeValue("node"));
               } catch (ParseException e) {
                   Log.error("Error parsing date", e);
               }
               if ("view".equals(item.attributeValue("action"))) {
                   // User requested to receive specific message
                   OfflineMessage offlineMsg = messageStore.getMessage(from.getNode(), creationDate);
                   if (offlineMsg != null) {
                       sendOfflineMessage(from, offlineMsg);
                   }
               }
               else if ("remove".equals(item.attributeValue("action"))) {
                   // User requested to delete specific message
                   messageStore.deleteMessage(from.getNode(), creationDate);
               }
           }
       }
       return reply;
   }
 

开发者ID:surevine,
项目名称:openfire-bespoke,
代码行数:43,
代码来源:IQOfflineMessagesHandler.java

示例16: initSession

点赞 2

import org.jivesoftware.openfire.OfflineMessage; //导入依赖的package包/类
/**
 * A session that has transitioned to available status must be initialized.
 * This includes:
 * <ul>
 * <li>Sending all offline presence subscription requests</li>
 * <li>Sending offline messages</li>
 * </ul>
 *
 * @param session The session being updated
 * @throws UserNotFoundException If the user being updated does not exist
 */
private void initSession(ClientSession session) throws UserNotFoundException {

    // Only user sessions need to be authenticated
    if (userManager.isRegisteredUser(session.getAddress().getNode())) {
        String username = session.getAddress().getNode();

        // Send pending subscription requests to user if roster service is enabled
        if (RosterManager.isRosterServiceEnabled()) {
            Roster roster = rosterManager.getRoster(username);
            for (RosterItem item : roster.getRosterItems()) {
                if (item.getRecvStatus() == RosterItem.RECV_SUBSCRIBE) {
                    session.process(createSubscribePresence(item.getJid(),
                            new JID(session.getAddress().toBareJID()), true));
                } else if (item.getRecvStatus() == RosterItem.RECV_UNSUBSCRIBE) {
                    session.process(createSubscribePresence(item.getJid(),
                            new JID(session.getAddress().toBareJID()), false));
                }
                if (item.getSubStatus() == RosterItem.SUB_TO
                        || item.getSubStatus() == RosterItem.SUB_BOTH) {
                    presenceManager.probePresence(session.getAddress(), item.getJid());
                }
            }
        }
        if (session.canFloodOfflineMessages()) {
        	
        	if(Log.isDebugEnabled()) {
        		Log.debug("Session " + session.getAddress() + " can flood offline");
        	}
        	
        	if (session.getPresence().getPriority() >-1) {
        		// deliver offline messages if any
        		Collection<OfflineMessage> messages = messageStore.getMessages(username, true);
            	
           		Log.info("Delivering " + messages.size() + " offline messages to " + session.getAddress());

            	for (Message message : messages) {
        			session.process(message);
        		}
        	}
        }
        else if(Log.isDebugEnabled()) {
    		Log.debug("Session " + session.getAddress() + " cannot flood offline");
    	}

    }
}
 

开发者ID:surevine,
项目名称:openfire-bespoke,
代码行数:58,
代码来源:PresenceUpdateHandler.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)