当前位置: 首页>>代码示例>>Java>>正文


Java Message.getType方法代码示例

本文整理汇总了Java中org.xmpp.packet.Message.getType方法的典型用法代码示例。如果您正苦于以下问题:Java Message.getType方法的具体用法?Java Message.getType怎么用?Java Message.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.xmpp.packet.Message的用法示例。


在下文中一共展示了Message.getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isSubjectChangeRequest

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Returns true if the given message qualifies as a subject change request for
 * the target MUC room, per XEP-0045. Note that this does not validate whether 
 * the sender has permission to make the change, because subject change requests
 * may be loaded from history or processed "live" during a user's session.
 * 
 * Refer to http://xmpp.org/extensions/xep-0045.html#subject-mod for details.
 * 
 * @return true if the given packet is a subject change request
 */
public boolean isSubjectChangeRequest(Message message) {
    
    // The subject is changed by sending a message of type "groupchat" to the <[email protected]>, 
    // where the <message/> MUST contain a <subject/> element that specifies the new subject 
    // but MUST NOT contain a <body/> element (or a <thread/> element).
    // Unfortunately, many clients do not follow these strict guidelines from the specs, so we
    // allow a lenient policy for detecting non-conforming subject change requests. This can be
    // configured by setting the "xmpp.muc.subject.change.strict" property to false (true by default).
    // An empty <subject/> value means that the room subject should be removed.

    return Message.Type.groupchat == message.getType() && 
            message.getSubject() != null && 
            (!isSubjectChangeStrict() || 
                (message.getBody() == null && 
                 message.getThread() == null));
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:27,代码来源:HistoryStrategy.java

示例2: process

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Handles Message packets sent to the pubsub service. Messages may be of type error
 * when an event notification was sent to a susbcriber whose address is no longer available.<p>
 *
 * Answers to authorization requests sent to node owners to approve pending subscriptions
 * will also be processed by this method.
 *
 * @param service the PubSub service this action is to be performed for.
 * @param message the Message packet sent to the pubsub service.
 */
public void process(PubSubService service, Message message) {
    if (message.getType() == Message.Type.error) {
        // Process Messages of type error to identify possible subscribers that no longer exist
        if (message.getError().getType() == PacketError.Type.cancel) {
            // TODO Assuming that owner is the bare JID (as defined in the JEP). This can be replaced with an explicit owner specified in the packet
            JID owner = message.getFrom().asBareJID();
            // Terminate the subscription of the entity to all nodes hosted at the service
           cancelAllSubscriptions(service, owner);
        }
        else if (message.getError().getType() == PacketError.Type.auth) {
            // TODO Queue the message to be sent again later (will retry a few times and
            // will be discarded when the retry limit is reached)
        }
    }
    else if (message.getType() == Message.Type.normal) {
        // Check that this is an answer to an authorization request
        DataForm authForm = (DataForm) message.getExtension("x", "jabber:x:data");
        if (authForm != null && authForm.getType() == DataForm.Type.submit) {
            String formType = authForm.getField("FORM_TYPE").getValues().get(0);
            // Check that completed data form belongs to an authorization request
            if ("http://jabber.org/protocol/pubsub#subscribe_authorization".equals(formType)) {
                // Process the answer to the authorization request
                processAuthorizationAnswer(service, authForm, message);
            }
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:38,代码来源:PubSubEngine.java

示例3: typeMatch

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private boolean typeMatch(Rule.PacketType rulePacketType, Packet packet) {
    // Simple case. Any.
    if (rulePacketType == Rule.PacketType.Any)
        return true;

    else if (packet instanceof Message) {
        Message message = (Message) packet;
        if (rulePacketType == Rule.PacketType.Message) {
            return true;
        }
        // Try some types.
        else if (rulePacketType == Rule.PacketType.MessageChat && message.getType() == Message.Type.chat) {
            return true;
        } else if (rulePacketType == Rule.PacketType.MessageGroupChat && message.getType() == Message.Type.groupchat) {
            return true;
        }
        return false;
    } else if (packet instanceof Presence) {
        if (rulePacketType == Rule.PacketType.Presence) {
            return true;
        } else
            return false;
    } else if (packet instanceof IQ) {
        if (rulePacketType == Rule.PacketType.Iq) {
            return true;
        } else
            return false;
    }

    return false;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:32,代码来源:PacketFilter.java

示例4: process

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Handles Message packets sent to the pubsub service. Messages may be of type error
 * when an event notification was sent to a susbcriber whose address is no longer available.<p>
 *
 * Answers to authorization requests sent to node owners to approve pending subscriptions
 * will also be processed by this method.
 *
 * @param service the PubSub service this action is to be performed for.
 * @param message the Message packet sent to the pubsub service.
 */
public void process(PubSubService service, Message message) {
    if (message.getType() == Message.Type.error) {
        // Process Messages of type error to identify possible subscribers that no longer exist
        if (message.getError().getType() == PacketError.Type.cancel) {
            // TODO Assuming that owner is the bare JID (as defined in the JEP). This can be replaced with an explicit owner specified in the packet
            JID owner = new JID(message.getFrom().toBareJID());
            // Terminate the subscription of the entity to all nodes hosted at the service
           cancelAllSubscriptions(service, owner);
        }
        else if (message.getError().getType() == PacketError.Type.auth) {
            // TODO Queue the message to be sent again later (will retry a few times and
            // will be discarded when the retry limit is reached)
        }
    }
    else if (message.getType() == Message.Type.normal) {
        // Check that this is an answer to an authorization request
        DataForm authForm = (DataForm) message.getExtension("x", "jabber:x:data");
        if (authForm != null && authForm.getType() == DataForm.Type.submit) {
            String formType = authForm.getField("FORM_TYPE").getValues().get(0);
            // Check that completed data form belongs to an authorization request
            if ("http://jabber.org/protocol/pubsub#subscribe_authorization".equals(formType)) {
                // Process the answer to the authorization request
                processAuthorizationAnswer(service, authForm, message);
            }
        }
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:38,代码来源:PubSubEngine.java

示例5: isConversation

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Returns true if the specified message should be processed by the conversation manager.
 * Only messages between two users, group chats, or gateways are processed.
 *
 * @param message the message to analyze.
 * @return true if the specified message should be processed by the conversation manager.
 */
boolean isConversation(Message message) {
    if (Message.Type.normal == message.getType() || Message.Type.chat == message.getType()) {
        // TODO: how should conversations with components on other servers be handled?
        return isConversationJID(message.getFrom()) && isConversationJID(message.getTo());
    }
    return false;
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:15,代码来源:ConversationManager.java

示例6: typeMatch

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private boolean typeMatch(Rule.PacketType rulePacketType, Packet packet) {
	// Simple case. Any.
	if (rulePacketType == Rule.PacketType.Any)
		return true;

	else if (packet instanceof Message) {
		Message message = (Message) packet;
		if (rulePacketType == Rule.PacketType.Message) {
			return true;
		}
		// Try some types.
		else if (rulePacketType == Rule.PacketType.MessageChat && message.getType() == Message.Type.chat) {
			return true;
		} else if (rulePacketType == Rule.PacketType.MessageGroupChat && message.getType() == Message.Type.groupchat) {
			return true;
		}
		return false;
	} else if (packet instanceof Presence) {
		if (rulePacketType == Rule.PacketType.Presence) {
			return true;
		} else
			return false;
	} else if (packet instanceof IQ) {
		if (rulePacketType == Rule.PacketType.Iq) {
			return true;
		} else
			return false;
	}

	return false;
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:32,代码来源:PacketFilter.java

示例7: isValidDistributableMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public static boolean isValidDistributableMessage(Packet packet) {
  if(!(packet instanceof Message)) {
    LOGGER.debug("isValidDistributableMessage : false packet is not a XMPP Message stanza");
    return false;
  }

  Message mmxMessage = (Message) packet;

  if (isMulticastMessage(mmxMessage)) {
    LOGGER.debug("isValidDistributableMessage :false packet is a Multicast message");
    return false;
  }
  
  if (isGeoEventMessage(mmxMessage)) {
    LOGGER.debug("isValidDistributableMessage :false packet is a GeoEvent message");
    return false;

  }
  if (isPubSubMessage(mmxMessage)) {
    LOGGER.debug("isValidDistributableMessage :false packet is a PubSub message");
    return false;
  }

  if(Strings.isNullOrEmpty(mmxMessage.getID())){
    LOGGER.debug("isValidDistributableMessage : false bad messageId={}", mmxMessage.getID());
    return false;
  }

  if(mmxMessage.getType() == Message.Type.error) {
    LOGGER.debug("isValidDistributableMessage : false message is an error message={}", mmxMessage.getID());
    return false;
  }

  if(mmxMessage.getTo() == null) {
    LOGGER.trace("isValidDistributableMessage : false toJID=null");
    return false;
  }

  if (isSignalMessage(mmxMessage)) {
    LOGGER.debug("isValidDistributableMessage :false packet is a signal message");
    return false;
  }

  return true;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:46,代码来源:MMXMessageUtil.java

示例8: shouldStoreMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Decide whether a message should be stored offline according to XEP-0160 and XEP-0334.
 *
 * @param message
 * @return <code>true</code> if the message should be stored offline, <code>false</code> otherwise.
 */
static boolean shouldStoreMessage(final Message message) {
    // XEP-0334: Implement the <no-store/> hint to override offline storage
    if (message.getChildElement("no-store", "urn:xmpp:hints") != null) {
        return false;
    }

    switch (message.getType()) {
        case chat:
            // XEP-0160: Messages with a 'type' attribute whose value is "chat" SHOULD be stored offline, with the exception of messages that contain only Chat State Notifications (XEP-0085) [7] content

            // Iterate through the child elements to see if we can find anything that's not a chat state notification or
            // real time text notification
            Iterator<?> it = message.getElement().elementIterator();

            while (it.hasNext()) {
                Object item = it.next();

                if (item instanceof Element) {
                    Element el = (Element) item;
                    if (Namespace.NO_NAMESPACE.equals(el.getNamespace())) {
                        continue;
                    }
                    if (!el.getNamespaceURI().equals("http://jabber.org/protocol/chatstates")
                            && !(el.getQName().equals(QName.get("rtt", "urn:xmpp:rtt:0")))
                            ) {
                        return true;
                    }
                }
            }

            return message.getBody() != null && !message.getBody().isEmpty();

        case groupchat:
        case headline:
            // XEP-0160: "groupchat" message types SHOULD NOT be stored offline
            // XEP-0160: "headline" message types SHOULD NOT be stored offline
            return false;

        case error:
            // XEP-0160: "error" message types SHOULD NOT be stored offline,
            // although a server MAY store advanced message processing errors offline
            if (message.getChildElement("amp", "http://jabber.org/protocol/amp") == null) {
                return false;
            }
            break;

        default:
            // XEP-0160: Messages with a 'type' attribute whose value is "normal" (or messages with no 'type' attribute) SHOULD be stored offline.
            break;
    }
    return true;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:59,代码来源:OfflineMessageStore.java

示例9: archiveMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void archiveMessage(Session session, Message message, boolean incoming)
{
    final XMPPServer server = XMPPServer.getInstance();
    final ArchivedMessage.Direction direction;
    final ArchivedMessage archivedMessage;
    final Conversation conversation;
    final JID ownerJid;
    final JID withJid;

    // TODO support groupchat
    if (message.getType() != Message.Type.chat && message.getType() != Message.Type.normal)
    {
        return;
    }

    if (server.isLocal(message.getFrom()) && incoming)
    {
        ownerJid = message.getFrom();
        withJid = message.getTo();
        // sent by the owner => to
        direction = ArchivedMessage.Direction.to;
    }
    else if (server.isLocal(message.getTo()) && ! incoming)
    {
        ownerJid = message.getTo();
        withJid = message.getFrom();
        // received by the owner => from
        direction = ArchivedMessage.Direction.from;
    }
    else
    {
        return;
    }

    archivedMessage = ArchiveFactory.createArchivedMessage(session, message, direction, withJid);
    if (archivedMessage.isEmpty())
    {
        return;
    }

    conversation = determineConversation(ownerJid, withJid, message.getSubject(), message.getThread(), archivedMessage);
    archivedMessage.setConversation(conversation);

    persistenceManager.createMessage(archivedMessage);
    if (indexManager != null)
    {
        indexManager.indexObject(archivedMessage);
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:50,代码来源:ArchiveManagerImpl.java

示例10: interceptPacket

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void interceptPacket(Packet packet, Session session, boolean read,
            boolean processed) throws PacketRejectedException {
    
    String emailTo = null;
    String emailFrom = null;

    if((!processed) && 
        (!read) && 
        (packet instanceof Message) && 
        (packet.getTo() != null)) { 

        Message msg = (Message) packet;
        
        if(msg.getType() == Message.Type.chat) {
        try {
            User userTo = userManager.getUser(packet.getTo().getNode());
            if(presenceManager.getPresence(userTo).toString().toLowerCase().indexOf("away") != -1) {
            // Status isn't away
            if(msg.getBody() != null) {
                // Build email/sms
                // The to email address
                emailTo = vcardManager.getVCardProperty(userTo.getUsername(), "EMAIL");
                if(emailTo == null || emailTo.length() == 0) {
                emailTo = vcardManager.getVCardProperty(userTo.getUsername(), "EMAIL:USERID");
                if(emailTo == null || emailTo.length() == 0) {
                    emailTo = userTo.getEmail();
                    if(emailTo == null || emailTo.length() == 0) {
                    emailTo = packet.getTo().getNode() + "@" + packet.getTo().getDomain();
                    }
                }
                }
                // The From email address
                User userFrom = userManager.getUser(packet.getFrom().getNode());
                emailFrom = vcardManager.getVCardProperty(userFrom.getUsername(), "EMAIL");
                if(emailFrom == null || emailFrom.length() == 0) {
                emailFrom = vcardManager.getVCardProperty(userFrom.getUsername(), "EMAIL:USERID");
                if(emailFrom == null || emailFrom.length() == 0) {
                    emailFrom = userFrom.getEmail();
                    if(emailFrom == null || emailFrom.length() == 0) {
                    emailFrom = packet.getFrom().getNode() + "@" + packet.getFrom().getDomain();
                    }
                }
                }

//			    System.err.println(vcardManager.getVCardProperty(userTo.getUsername(), "EMAIL:USERID"));
                // Send email/sms
                // if this is an sms... modify the recipient address
                emailService.sendMessage(userTo.getName(), 
                emailTo, 
                userFrom.getName(), 
                emailFrom,
                "IM",
                msg.getBody(), 
                null);
                
                // Notify the sender that this went to email/sms
                messageRouter.route(createServerMessage(packet.getFrom().getNode() + "@" + packet.getFrom().getDomain(), packet.getTo().getNode() + "@" + packet.getTo().getDomain(), emailTo));

            }
            }
        } catch (UserNotFoundException e) {
        }
        }
    }
    }
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:66,代码来源:emailOnAway.java

示例11: storeOffline

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void storeOffline(Message message) {
    if (message != null) {
        // Do nothing if the message was sent to the server itself, an anonymous user or a non-existent user
        JID recipientJID = message.getTo();
        if (recipientJID == null || serverAddress.equals(recipientJID) ||
                recipientJID.getNode() == null ||
                !UserManager.getInstance().isRegisteredUser(recipientJID.getNode())) {
            return;
        }
        // Do not store messages of type groupchat, error or headline as specified in JEP-160
        if (Message.Type.groupchat == message.getType() ||
                Message.Type.error == message.getType() ||
                Message.Type.headline == message.getType()) {
            return;
        }
        // Do not store messages if communication is blocked
        PrivacyList list =
                PrivacyListManager.getInstance().getDefaultPrivacyList(recipientJID.getNode());
        if (list != null && list.shouldBlockPacket(message)) {
            return;
        }

        if (type == Type.bounce) {
            bounce(message);
        }
        else if (type == Type.store) {
            store(message);
        }
        else if (type == Type.store_and_bounce) {
            if (underQuota(message)) {
                store(message);
            }
            else {
                bounce(message);
            }
        }
        else if (type == Type.store_and_drop) {
            if (underQuota(message)) {
                store(message);
            }
        }
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:44,代码来源:OfflineMessageStrategy.java

示例12: shouldStoreMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Decide whether a message should be stored offline according to XEP-0160 and XEP-0334.
 *
 * @param message
 * @return <code>true</code> if the message should be stored offline, <code>false</code> otherwise.
 */
static boolean shouldStoreMessage(final Message message) {
    // XEP-0334: Implement the <no-store/> hint to override offline storage
    if (message.getChildElement("no-store", "urn:xmpp:hints") != null) {
        return false;
    }

    switch (message.getType()) {
        case chat:
            // XEP-0160: Messages with a 'type' attribute whose value is "chat" SHOULD be stored offline, with the exception of messages that contain only Chat State Notifications (XEP-0085) [7] content

            // Iterate through the child elements to see if we can find anything that's not a chat state notification or
            // real time text notification
            Iterator<?> it = message.getElement().elementIterator();

            while (it.hasNext()) {
                Object item = it.next();

                if (item instanceof Element) {
                    Element el = (Element) item;

                    if (!el.getNamespaceURI().equals("http://jabber.org/protocol/chatstates")
                            && !(el.getQName().equals(QName.get("rtt", "urn:xmpp:rtt:0")))
                            ) {
                        return true;
                    }
                }
            }

            return false;

        case groupchat:
        case headline:
            // XEP-0160: "groupchat" message types SHOULD NOT be stored offline
            // XEP-0160: "headline" message types SHOULD NOT be stored offline
            return false;

        case error:
            // XEP-0160: "error" message types SHOULD NOT be stored offline,
            // although a server MAY store advanced message processing errors offline
            if (message.getChildElement("amp", "http://jabber.org/protocol/amp") == null) {
                return false;
            }
            break;

        default:
            // XEP-0160: Messages with a 'type' attribute whose value is "normal" (or messages with no 'type' attribute) SHOULD be stored offline.
            break;
    }
    return true;
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:57,代码来源:OfflineMessageStore.java

示例13: storeOffline

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void storeOffline(Message message) {
    if (message != null) {
        // Do nothing if the message was sent to the server itself, an anonymous user or a non-existent user
        JID recipientJID = message.getTo();
        if (recipientJID == null || serverAddress.equals(recipientJID) ||
                recipientJID.getNode() == null ||
                !UserManager.getInstance().isRegisteredUser(recipientJID.getNode())) {
            return;
        }
        // Do not store messages of type groupchat, error or headline as specified in JEP-160
        if (Message.Type.groupchat == message.getType() ||
                Message.Type.error == message.getType() ||
                Message.Type.headline == message.getType()) {
            return;
        }
        // Do not store messages if communication is blocked
        PrivacyList list =
                PrivacyListManager.getInstance().getDefaultPrivacyList(recipientJID.getNode());
        if (list != null && list.shouldBlockPacket(message)) {
            Message result = message.createCopy();
            result.setTo(message.getFrom());
            result.setError(PacketError.Condition.service_unavailable);
            XMPPServer.getInstance().getRoutingTable().routePacket(message.getFrom(), result, true);
            return;
        }

        if (type == Type.bounce) {
            bounce(message);
        }
        else if (type == Type.store) {
            store(message);
        }
        else if (type == Type.store_and_bounce) {
            if (underQuota(message)) {
                store(message);
            }
            else {
                bounce(message);
            }
        }
        else if (type == Type.store_and_drop) {
            if (underQuota(message)) {
                store(message);
            }
        }
    }
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:48,代码来源:OfflineMessageStrategy.java

示例14: isConversation

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Returns true if the specified message should be processed by the conversation manager. Only messages between two users, group chats, or
 * gateways are processed.
 *
 * @param message
 *            the message to analyze.
 * @return true if the specified message should be processed by the conversation manager.
 */
boolean isConversation(Message message) {
    if (Message.Type.normal == message.getType() || Message.Type.chat == message.getType()) {
        // TODO: how should conversations with components on other servers be handled?
        return isConversationJID(message.getFrom()) && isConversationJID(message.getTo());
    }
    return false;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:16,代码来源:ConversationManager.java

示例15: isConversation

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Returns true if the specified message should be processed by the conversation manager. Only messages between two users, group chats, or
 * gateways are processed.
 * 
 * @param message
 *            the message to analyze.
 * @return true if the specified message should be processed by the conversation manager.
 */
boolean isConversation(Message message) {
	if (Message.Type.normal == message.getType() || Message.Type.chat == message.getType()) {
		// TODO: how should conversations with components on other servers be handled?
		return isConversationJID(message.getFrom()) && isConversationJID(message.getTo());
	}
	return false;
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:16,代码来源:ConversationManager.java


注:本文中的org.xmpp.packet.Message.getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。