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


Java Message.getBody方法代码示例

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


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

示例1: handleStatistic

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private void handleStatistic(Message message, String subdomain, String statistic) {
	String body = message.getBody();
	// we dont catch this with exception so we can see what might go wrong. Sometimes S2 responded not knowing the
	// command but i dont really know why
	if (body.startsWith("Unknown command."))
		return;

	int value;
	try {
		value = Integer.parseInt(body);
		gojaraAdminManager.putStatisticValue(subdomain, statistic, value);
	} catch (Exception e) {
		e.printStackTrace();
	}

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

示例2: process

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void process(Message packet) {
    if (packet.getBody() == null) {
        // TODO Handle statistics reported by the agents????
        // ignore this packet
        return;
    }
    // Get the chatbot of the workgroup. It is not mandatory for workgroups to have a chatbot
    // so if no chatbot was defined for the workgroup then do nothing
    Chatbot bot = workgroup.getChatBot();
    if (bot != null) {
        // Get the chatbot session of the user (create one if necessary)
        ChatbotSession session = bot.getSession(packet.getFrom(), true);
        // Let the bot process the received message
        bot.onMessage(session, packet);
    }
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:17,代码来源:MessageHandler.java

示例3: privateMessageRecieved

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void privateMessageRecieved(JID toJID, JID fromJID, Message message) {
    if(message.getBody() != null) {
         if (ClusterManager.isSeniorClusterMember()) {
             conversationManager.processMessage(fromJID, toJID, message.getBody(), new Date());
         }
         else {
             ConversationEventsQueue eventsQueue = conversationManager.getConversationEventsQueue();
             eventsQueue.addChatEvent(conversationManager.getConversationKey(fromJID, toJID),
                     ConversationEvent.chatMessageReceived(toJID, fromJID,
                             conversationManager.isMessageArchivingEnabled() ? message.getBody() : null,
                             new Date()));
         }
     }
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:15,代码来源:GroupConversationInterceptor.java

示例4: ConversationLogEntry

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Creates a new ConversationLogEntry that registers that a given message was sent to a given
 * room on a given date.
 * 
 * @param date the date when the message was sent to the room.
 * @param room the room that received the message.
 * @param message the message to log as part of the conversation in the room.
 * @param sender the real XMPPAddress of the sender (e.g. [email protected]). 
 */
public ConversationLogEntry(Date date, MUCRoom room, Message message, JID sender) {
    this.date = date;
    this.subject = message.getSubject();
    this.body = message.getBody();
    this.stanza = message.toString();
    this.sender = sender;
    this.roomID = room.getID();
    this.nickname = message.getFrom().getResource();
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:19,代码来源:ConversationLogEntry.java

示例5: interceptPacket

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void interceptPacket(Packet packet, Session session, boolean incoming, boolean processed)
        throws PacketRejectedException
{
    // Ignore any packets that haven't already been processed by interceptors.
    if (!processed) {
        return;
    }
    if (packet instanceof Message) {
        // Ignore any outgoing messages (we'll catch them when they're incoming).
        if (!incoming) {
            return;
        }
        Message message = (Message) packet;
        // Ignore any messages that don't have a body so that we skip events.
        // Note: XHTML messages should always include a body so we should be ok. It's
        // possible that we may need special XHTML filtering in the future, however.
        if (message.getBody() != null) {
            // Only process messages that are between two users, group chat rooms, or gateways.
            if (conversationManager.isConversation(message)) {
                // Process this event in the senior cluster member or local JVM when not in a cluster
                if (ClusterManager.isSeniorClusterMember()) {
                    conversationManager.processMessage(message.getFrom(), message.getTo(), message.getBody(), message.toXML(), new Date());
                }
                else {
                    JID sender = message.getFrom();
                    JID receiver = message.getTo();
                    ConversationEventsQueue eventsQueue = conversationManager.getConversationEventsQueue();
                    eventsQueue.addChatEvent(conversationManager.getConversationKey(sender, receiver),
                            ConversationEvent.chatMessageReceived(sender, receiver,
                                    conversationManager.isMessageArchivingEnabled() ? message.getBody() : null,
                                    new Date()));
                }
            }
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:37,代码来源:ArchiveInterceptor.java

示例6: interceptPacket

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void interceptPacket(Packet packet, Session session, boolean incoming, boolean processed)
        throws PacketRejectedException
{
    // Ignore any packets that haven't already been processed by interceptors.
    if (!processed) {
        return;
    }
    if (packet instanceof Message) {
        // Ignore any outgoing messages (we'll catch them when they're incoming).
        if (!incoming) {
            return;
        }
        Message message = (Message) packet;
        // Ignore any messages that don't have a body so that we skip events.
        // Note: XHTML messages should always include a body so we should be ok. It's
        // possible that we may need special XHTML filtering in the future, however.
        if (message.getBody() != null) {
            // Only process messages that are between two users, group chat rooms, or gateways.
            if (conversationManager.isConversation(message)) {
                // Process this event in the senior cluster member or local JVM when not in a cluster
                if (ClusterManager.isSeniorClusterMember()) {
                    conversationManager.processMessage(message.getFrom(), message.getTo(), message.getBody(), new Date());
                }
                else {
                    JID sender = message.getFrom();
                    JID receiver = message.getTo();
                    ConversationEventsQueue eventsQueue = conversationManager.getConversationEventsQueue();
                    eventsQueue.addChatEvent(conversationManager.getConversationKey(sender, receiver),
                            ConversationEvent.chatMessageReceived(sender, receiver,
                                    conversationManager.isMessageArchivingEnabled() ? message.getBody() : null,
                                    new Date()));
                }
            }
        }
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:37,代码来源:ArchiveInterceptor.java

示例7: processMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private void processMessage(Message message, boolean targetSrv,boolean canProceed) {


		if (targetSrv) {

			String to = message.getFrom().toBareJID();
		   	String body = message.getBody();
			String xmppdomain = "@" + JiveGlobals.getProperty("xmpp.domain");

			Log.debug("ServerInfo - Message received");
			Log.debug("ServerInfo - Original message from: " + to);
			Log.debug("ServerInfo - Original message body: " + body);

			MyMessage_OF MyMsg = new MyMessage_OF();
			String text = MyMsg.returnMessage(body);

			Message newMessage = new Message();
			newMessage.setTo(to);
			newMessage.setFrom("[email protected]"+JiveGlobals.getProperty("xmpp.domain"));
			newMessage.setSubject("Resultado");
			newMessage.setBody(text);

			Log.debug("ServerInfo - Return message to: " + to);
			Log.debug("ServerInfo - Return message from: " + "[email protected]"+JiveGlobals.getProperty("xmpp.domain"));
			Log.debug("ServerInfo - Return message body: " + text);

			try {

				componentManager.sendPacket(this, newMessage);
			} catch (Exception e) {

				Log.error(e.getMessage(), e);
			}
		}
	}
 
开发者ID:mhterres,项目名称:ServerInfo,代码行数:36,代码来源:ServerInfoPlugin.java

示例8: test2Build

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Test with content containing XML characters.
 * @throws Exception
 */
@Test
public void test2Build() throws Exception {
  SendMessageRequest request = new SendMessageRequest();
  request.setRecipientUserIds(Collections.singletonList("test"));
  String message = "<message><subject>This is a test</subject><content>Tell me a story</content></message>";

  Map<String, String> contentMap = new HashMap<String, String>();
  contentMap.put("content", message);
  contentMap.put("contentType", "text");
  request.setContent(contentMap);
  request.setReceipt(true);

  AppEntity app = new AppEntity();
  app.setAppId("i1cglsw8dsa");
  app.setServerUserId("admin");
  String msgId = new MessageIdGeneratorImpl().generateItemIdentifier(app.getAppId());

  MessageBuilder builder = new MessageBuilder();
  builder.setAppId(app.getAppId());
  builder.setDomain("localhost");
  builder.setMetadata(request.getContent());
  builder.setUtcTime(System.currentTimeMillis());
  builder.setId(msgId);
  builder.setSenderId(app.getServerUserId());
  builder.setUserId(request.getRecipientUserIds().get(0));
  Message m = builder.build();
  assertNotNull("Message shouldn't be null", m);
  Element mmx = m.getChildElement(Constants.MMX, Constants.MMX_NS_MSG_PAYLOAD);
  assertNotNull("mmx element is null", mmx);
  Element payload = mmx.element(Constants.MMX_PAYLOAD);
  assertNotNull("payload element is null", payload);
  String content = payload.getText();
  assertNotNull("payload content is null", content);
  assertEquals("Non matching content", "", content);

  JID from = m.getFrom();
  assertEquals ("Non matching from jid", "admin%[email protected]", from.toString());
  String body = m.getBody();
  assertEquals("Message body is not expected", MMXServerConstants.MESSAGE_BODY_DOT, body);
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:45,代码来源:MessageBuilderTest.java

示例9: processPacket

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Handle the receied packet and answer the weather information of the requested station id.
 * The request must be made using Message packets where the body of the message should be the
 * station id.<p>
 *
 * Note: I don't know the list of valid station ids so if you find the list please send it to me
 * so I can add it to this example.
 *
 * @param packet the Message requesting information about a certain station id.
 */
public void processPacket(Packet packet) {
    System.out.println("Received package:"+packet.toXML());
    // Only process Message packets
    if (packet instanceof Message) {
        // Get the requested station to obtain it's weather information
        Message message = (Message) packet;
        String station = message.getBody();
        // Send the request and get the weather information
        Metar metar = Weather.getMetar(station, 5000);

        // Build the answer
        Message reply = new Message();
        reply.setTo(message.getFrom());
        reply.setFrom(message.getTo());
        reply.setType(message.getType());
        reply.setThread(message.getThread());

        // Append the discovered information if something was found
        if (metar != null) {
            StringBuilder sb = new StringBuilder();
            sb.append("station id : " + metar.getStationID());
            sb.append("\rwind dir   : " + metar.getWindDirection() + " degrees");
            sb.append("\rwind speed : " + metar.getWindSpeedInMPH() + " mph, " +
                                                 metar.getWindSpeedInKnots() + " knots");
            if (!metar.getVisibilityLessThan()) {
                sb.append("\rvisibility : " + metar.getVisibility() + " mile(s)");
            } else {
                sb.append("\rvisibility : < " + metar.getVisibility() + " mile(s)");
            }

            sb.append("\rpressure   : " + metar.getPressure() + " in Hg");
            sb.append("\rtemperaturePrecise: " +
                               metar.getTemperaturePreciseInCelsius() + " C, " +
                               metar.getTemperaturePreciseInFahrenheit() + " F");
            sb.append("\rtemperature: " +
                               metar.getTemperatureInCelsius() + " C, " +
                               metar.getTemperatureInFahrenheit() + " F");
            sb.append("\rtemperatureMostPrecise: " +
                               metar.getTemperatureMostPreciseInCelsius() + " C, " +
                               metar.getTemperatureMostPreciseInFahrenheit() + " F");
            reply.setBody(sb.toString());
        }
        else {
            // Answer that the requested station id does not exist
            reply.setBody("Unknown station ID");
        }

        // Send the response to the sender of the request
        try {
            ComponentManagerFactory.getComponentManager().sendPacket(this, reply);
        } catch (ComponentException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Whack,代码行数:66,代码来源:WeatherComponent.java

示例10: sendHistory

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Sends the smallest amount of traffic that meets any combination of the requested criteria.
 * 
 * @param joinRole the user that will receive the history.
 * @param roomHistory the history of the room.
 */
public void sendHistory(LocalMUCRole joinRole, MUCRoomHistory roomHistory) {
    if (!isConfigured()) {
        Iterator<Message> history = roomHistory.getMessageHistory();
        while (history.hasNext()) {
            joinRole.send(history.next());
        }
    }
    else {
        if (getMaxChars() == 0) {
            // The user requested to receive no history
            return;
        }
        int accumulatedChars = 0;
        int accumulatedStanzas = 0;
        Element delayInformation;
        LinkedList<Message> historyToSend = new LinkedList<>();
        ListIterator<Message> iterator = roomHistory.getReverseMessageHistory();
        while (iterator.hasPrevious()) {
            Message message = iterator.previous();
            // Update number of characters to send
            String text = message.getBody() == null ? message.getSubject() : message.getBody();
            if (text == null) {
                // Skip this message since it has no body and no subject  
                continue;
            }
            accumulatedChars += text.length();
            if (getMaxChars() > -1 && accumulatedChars > getMaxChars()) {
                // Stop collecting history since we have exceded a limit
                break;
            }
            // Update number of messages to send
            accumulatedStanzas ++;
            if (getMaxStanzas() > -1 && accumulatedStanzas > getMaxStanzas()) {
                // Stop collecting history since we have exceded a limit
                break;
            }

            if (getSeconds() > -1 || getSince() != null) {
                delayInformation = message.getChildElement("delay", "urn:xmpp:delay");
                try {
                    // Get the date when the historic message was sent
                    Date delayedDate = xmppDateTime.parseString(delayInformation.attributeValue("stamp"));
                    if (getSince() != null && delayedDate != null && delayedDate.before(getSince())) {
                        // Stop collecting history since we have exceded a limit
                        break;
                    }
                    if (getSeconds() > -1) {
                        Date current = new Date();
                        long diff = (current.getTime() - delayedDate.getTime()) / 1000;
                        if (getSeconds() <= diff) {
                            // Stop collecting history since we have exceded a limit
                            break;
                        }
                    }
                }
                catch (Exception e) {
                    Log.error("Error parsing date from historic message", e);
                }

            }

            historyToSend.addFirst(message);
        }
        // Send the smallest amount of traffic to the user
        for (Object aHistoryToSend : historyToSend) {
            joinRole.send((Message) aHistoryToSend);
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:76,代码来源:HistoryRequest.java

示例11: logConversation

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void logConversation(MUCRoom room, Message message, JID sender) {
    // Only log messages that have a subject or body. Otherwise ignore it.
    if (message.getSubject() != null || message.getBody() != null) {
        logQueue.add(new ConversationLogEntry(new Date(), room, message, sender));
    }
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:7,代码来源:MultiUserChatServiceImpl.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 (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

示例13: sendViolationNotification

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private void sendViolationNotification(Packet originalPacket) {
    String subject = "Content filter notification! ("
            + originalPacket.getFrom().getNode() + ")";

    String body;
    if (originalPacket instanceof Message) {
        Message originalMsg = (Message) originalPacket;
        body = "Disallowed content detected in message from:"
                + originalMsg.getFrom()
                + " to:"
                + originalMsg.getTo()
                + ", message was "
                + (allowOnMatch ? "allowed" + (contentFilter.isMaskingContent() ? " and masked." : " but not masked.") : "rejected.")
                + (violationIncludeOriginalPacketEnabled ? "\nOriginal subject:"
                        + (originalMsg.getSubject() != null ? originalMsg
                                .getSubject() : "")
                        + "\nOriginal content:"
                        + (originalMsg.getBody() != null ? originalMsg
                                .getBody() : "")
                        : "");

    } else {
        // presence
        Presence originalPresence = (Presence) originalPacket;
        body = "Disallowed status detected in presence from:"
                + originalPresence.getFrom()
                + ", status was "
                + (allowOnMatch ? "allowed" + (contentFilter.isMaskingContent() ? " and masked." : " but not masked.") : "rejected.")
                + (violationIncludeOriginalPacketEnabled ? "\nOriginal status:"
                        + originalPresence.getStatus()
                        : "");
    }

    if (violationNotificationByIMEnabled) {

        if (Log.isDebugEnabled()) {
            Log.debug("Content filter: sending IM notification");
        }
        sendViolationNotificationIM(subject, body);
    }

    if (violationNotificationByEmailEnabled) {

        if (Log.isDebugEnabled()) {
            Log.debug("Content filter: sending email notification");
        }
        sendViolationNotificationEmail(subject, body);
    }
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:50,代码来源:ContentFilterPlugin.java

示例14: processMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private void processMessage(Message message, boolean targetSrv,boolean canProceed) {

		if (targetSrv)	{

			String to = message.getFrom().toBareJID();
			String body = message.getBody();
			String xmppdomain = "@" + JiveGlobals.getProperty("xmpp.domain");
			String text="";
			Boolean authUse = false;

			Log.debug("B9 - Message received");
			Log.debug("B9 - Original message from: " + to);
			Log.debug("B9 - Original message body: " + body);

			MyMessage_B9 MyMsg = new MyMessage_B9();

                        Log.debug("B9 - Processing message received.");
                        Log.debug("B9 - Verifying user access.");

			if (!adminManager.isUserAdmin(message.getFrom(),false)) {

				Log.debug("B9 - JID " + message.getFrom() + " is not admin.");
				text="JID " + to + " is not an Openfire Administrator.";
			}
			else {
			
				Log.debug("B9 - JID " + message.getFrom() + " is admin.");
				text = MyMsg.returnMessage(body,"XMPP");
			}

			Message newMessage = new Message();
			newMessage.setTo(to);
			newMessage.setFrom("[email protected]"+JiveGlobals.getProperty("xmpp.domain"));
			newMessage.setSubject("Resultado");
			newMessage.setBody(text);

			Log.debug("B9 - Return message to: " + to);
			Log.debug("B9 - Return message from: " + "[email protected]"+JiveGlobals.getProperty("xmpp.domain"));
			Log.debug("B9 - Return message body: " + text);

			try {

				componentManager.sendPacket(this, newMessage);
			} 
			catch (Exception e) {

				Log.error(e.getMessage(), e);
			}
		}
	}
 
开发者ID:mhterres,项目名称:b9,代码行数:51,代码来源:B9Plugin.java

示例15: addMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Adds a message to this message store. Messages will be stored and made
 * available for later delivery.
 *
 * @param message the message to store.
 */
public void addMessage(Message message) {
    if (message == null) {
        return;
    }
    if (message.getBody() == null || message.getBody().length() == 0) {
    	// ignore empty bodied message (typically chat-state notifications).
    	return;
    }
    JID recipient = message.getTo();
    String username = recipient.getNode();
    // If the username is null (such as when an anonymous user), don't store.
    if (username == null || !UserManager.getInstance().isRegisteredUser(recipient)) {
        return;
    }
    else
    if (!XMPPServer.getInstance().getServerInfo().getXMPPDomain().equals(recipient.getDomain())) {
        // Do not store messages sent to users of remote servers
        return;
    }

    long messageID = SequenceManager.nextID(JiveConstants.OFFLINE);

    // Get the message in XML format.
    String msgXML = message.getElement().asXML();

    Connection con = null;
    PreparedStatement pstmt = null;
    try {
        con = DbConnectionManager.getConnection();
        pstmt = con.prepareStatement(INSERT_OFFLINE);
        pstmt.setString(1, username);
        pstmt.setLong(2, messageID);
        pstmt.setString(3, StringUtils.dateToMillis(new java.util.Date()));
        pstmt.setInt(4, msgXML.length());
        pstmt.setString(5, msgXML);
        pstmt.executeUpdate();
    }

    catch (Exception e) {
        Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
    }
    finally {
        DbConnectionManager.closeConnection(pstmt, con);
    }

    // Update the cached size if it exists.
    if (sizeCache.containsKey(username)) {
        int size = sizeCache.get(username);
        size += msgXML.length();
        sizeCache.put(username, size);
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:59,代码来源:OfflineMessageStore.java


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