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


Java Message.setBody方法代码示例

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


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

示例1: sendErrorMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private void sendErrorMessage(String body) {
    // Invitation request has failed. Inform inviter
    userRequest.removeRelatedRequest(this);

    Message message = new Message();
    message.setError(PacketError.Condition.recipient_unavailable);
    message.setTo(inviter);
    message.setFrom(workgroup.getJID());
    message.setBody(body);
    Element element = message.addChildElement("invite", "http://jabber.org/protocol/workgroup");
    element.addAttribute("type", type.toString());
    Element sessionElement = element.addElement("session", "http://jivesoftware.com/protocol/workgroup");
    sessionElement.addAttribute("id", sessionID);
    element.addElement("inviter").setText(inviter.toString());
    element.addElement("invitee").setText(invitee.toString());
    workgroup.send(message);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:18,代码来源:InvitationRequest.java

示例2: lock

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void lock(MUCRole senderRole) throws ForbiddenException {
    if (MUCRole.Affiliation.owner != senderRole.getAffiliation()) {
        throw new ForbiddenException();
    }
    if (isLocked()) {
        // Do nothing if the room was already locked
        return;
    }
    setLocked(true);
    if (senderRole.getUserAddress() != null) {
        // Send to the occupant that locked the room a message saying so
        Message message = new Message();
        message.setType(Message.Type.groupchat);
        message.setBody(LocaleUtils.getLocalizedString("muc.locked"));
        message.setFrom(getRole().getRoleAddress());
        senderRole.send(message);
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:19,代码来源:LocalMUCRoom.java

示例3: testFilterMessageBodyWithMask

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void testFilterMessageBodyWithMask() {

        // filter on the word "fox" and "dog"
        filter.setPatterns("fox,dog");
        filter.setMask("**");

        // test message
        Message message = new Message();
        message.setBody("the quick brown fox jumped over the lazy dog");
        boolean matched = filter.filter(message);

        // matches should not be found
        assertTrue(matched);

        // content has changed
        assertEquals("the quick brown ** jumped over the lazy **", message
                .getBody());
        assertNull(message.getSubject());

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

示例4: sendErrorMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private void sendErrorMessage(String body) {
    // Invitation request has failed. Inform inviter
    userRequest.removeRelatedRequest(this);

    Message message = new Message();
    message.setError(PacketError.Condition.recipient_unavailable);
    message.setTo(inviter);
    message.setFrom(workgroup.getJID());
    message.setBody(body);
    Element element = message.addChildElement("transfer", "http://jabber.org/protocol/workgroup");
    element.addAttribute("type", type.toString());
    Element sessionElement = element.addElement("session", "http://jivesoftware.com/protocol/workgroup");
    sessionElement.addAttribute("id", sessionID);
    element.addElement("inviter").setText(inviter.toString());
    element.addElement("invitee").setText(invitee.toString());
    workgroup.send(message);
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:18,代码来源:TransferRequest.java

示例5: testFilterMessageBody

import org.xmpp.packet.Message; //导入方法依赖的package包/类
@Test
public void testFilterMessageBody() {

    // filter on the word fox
    filter.setPatterns("fox");

    // test message
    Message message = new Message();
    message.setBody("the quick brown fox jumped over the lazy dog");
    boolean matched = filter.filter(message);

    // matches should be found
    assertTrue(matched);

    // content has not changed as there is no content mask
    assertEquals("the quick brown fox jumped over the lazy dog", message
            .getBody());
    assertNull(message.getSubject());
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:20,代码来源:ContentFilterTest.java

示例6: main

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * @param args
 * @throws EvalError
 */
public static void main(String[] args) throws EvalError {
    Message message = new Message();
    message.setTo("[email protected]");
    message.setFrom("mim.snda");
    message.setBody("asdfqwerqwer阿斯顿发达");
    Interpreter i = new Interpreter(); // Construct an interpreter
    long start = TimeUtil.currentTimeMillis();
    for (int j = 0; j < 100; j++) {
        i.set("message", message); // Set variables
        System.out.println(i.eval("message.to.node"));
        i.unset("message");
    }
    System.out.println((TimeUtil.currentTimeMillis() - start) + "ms");
}
 
开发者ID:blusechen,项目名称:venus,代码行数:19,代码来源:XmppBeanShellTest.java

示例7: sendLastPublishedItem

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private boolean sendLastPublishedItem(PublishedItem publishedItem,
                                          NodeSubscription subNode, JID to) {
    if (!subNode.canSendPublicationEvent(publishedItem.getNode(), publishedItem)) {
      return false;
    }
    Node node = subNode.getNode();
    Message notification = new Message();
    Element event = notification.getElement()
            .addElement("event", "http://jabber.org/protocol/pubsub#event");
    Element items = event.addElement("items");
    items.addAttribute("node", node.getNodeID());
    Element item = items.addElement("item");
    if (publishedItem.getNode().isItemRequired()) {
        item.addAttribute("id", publishedItem.getID());
    }
    if (node.isPayloadDelivered() && publishedItem.getPayload() != null) {
        item.add(publishedItem.getPayload().createCopy());
    }
    // Add a message body (if required)
    if (subNode.isIncludingBody()) {
        notification.setBody(LocaleUtils.getLocalizedString("pubsub.notification.message.body"));
    }
    // Include date when published item was created
    notification.getElement().addElement("delay", "urn:xmpp:delay")
            .addAttribute("stamp", XMPPDateTimeFormat.format(publishedItem.getCreationDate()));
    // Send the event notification to the subscriber
    node.getService().sendNotification(node, notification, to);
//    node.getService().sendNotification(node, notification, subNode.getJID());
    return true;
  }
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:31,代码来源:MMXChannelManager.java

示例8: sendLastPublishedItems

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private boolean sendLastPublishedItems(List<PublishedItem> publishedItems,
                                         NodeSubscription subNode, JID to) {
  PublishedItem pubItem = publishedItems.get(0);
  if (!subNode.canSendPublicationEvent(pubItem.getNode(), pubItem)) {
    return false;
  }
  Node node = subNode.getNode();
  Message notification = new Message();
  Element event = notification.getElement().addElement("event",
          "http://jabber.org/protocol/pubsub#event");
  Element items = event.addElement("items");
  items.addAttribute("node", node.getNodeID());
  for (PublishedItem publishedItem : publishedItems) {
    Element item = items.addElement("item");
    if (publishedItem.getNode().isItemRequired()) {
      item.addAttribute("id", publishedItem.getID());
    }
    if (node.isPayloadDelivered() && publishedItem.getPayload() != null) {
      item.add(publishedItem.getPayload().createCopy());
    }
  }
  // Add a message body (if required)
  if (subNode.isIncludingBody()) {
    notification.setBody(LocaleUtils
        .getLocalizedString("pubsub.notification.message.body"));
  }
  // Include date when published item was created
  notification
      .getElement()
      .addElement("delay", "urn:xmpp:delay")
      .addAttribute("stamp",
              XMPPDateTimeFormat.format(pubItem.getCreationDate()));
  // Send the event notification to the subscriber
  node.getService().sendNotification(node, notification, to);
  // node.getService().sendNotification(node, notification, subNode.getJID());
  return true;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:38,代码来源:MMXChannelManager.java

示例9: sendLastPublishedItems

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private boolean sendLastPublishedItems(List<PublishedItem> publishedItems,
                                         NodeSubscription subNode, JID to) {
  PublishedItem pubItem = publishedItems.get(0);
  if (!subNode.canSendPublicationEvent(pubItem.getNode(), pubItem)) {
    return false;
  }
  Node node = subNode.getNode();
  Message notification = new Message();
  Element event = notification.getElement().addElement("event",
      "http://jabber.org/protocol/pubsub#event");
  Element items = event.addElement("items");
  items.addAttribute("node", node.getNodeID());
  for (PublishedItem publishedItem : publishedItems) {
    Element item = items.addElement("item");
    if (publishedItem.getNode().isItemRequired()) {
      item.addAttribute("id", publishedItem.getID());
    }
    if (node.isPayloadDelivered() && publishedItem.getPayload() != null) {
      item.add(publishedItem.getPayload().createCopy());
    }
  }
  // Add a message body (if required)
  if (subNode.isIncludingBody()) {
    notification.setBody(LocaleUtils
        .getLocalizedString("pubsub.notification.message.body"));
  }
  // Include date when published item was created
  notification
      .getElement()
      .addElement("delay", "urn:xmpp:delay")
      .addAttribute("stamp",
          XMPPDateTimeFormat.format(pubItem.getCreationDate()));
  // Send the event notification to the subscriber
  node.getService().sendNotification(node, notification, to);
  // node.getService().sendNotification(node, notification, subNode.getJID());
  return true;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:38,代码来源:MMXTopicManager.java

示例10: testDistribute1

import org.xmpp.packet.Message; //导入方法依赖的package包/类
@Test
public void testDistribute1() throws InterruptedException {
  MessageDistributor distributor = new StubMessageDistributorImpl();
  Message message = new Message();
  message.setBody("body");
  message.setSubject("subject");
  String toNode1 = "magnet.way";
  String fromNode = "thomas";
  String appKey = "AAABSNIBKOstQST7";
  String host = "mmx.magnet.com";
  String resource = "device1";
  message.setTo(new JID(toNode1 + JIDUtil.APP_ID_DELIMITER + appKey, host, resource));
  message.setFrom(new JID(fromNode + JIDUtil.APP_ID_DELIMITER + appKey, host, resource));

  MessageDistributor.DistributionContext context = new DistributionContextImpl(toNode1, appKey, host, resource);

  PacketRouter router = new CountingPacketRouter();
  MMXPresenceFinder finder = new AlwaysOnlinePresenceFinder();
  ((StubMessageDistributorImpl) distributor).setPacketRouter(router);
  ((StubMessageDistributorImpl) distributor).setPresenceFinder(finder);

  MessageDistributor.DistributionResult result = distributor.distribute(message, context);

  try {
    Thread.sleep(5000);
  } catch (InterruptedException e) {
    System.out.println("testDistribute1 thread is interrupted");
  }

  CountingPacketRouter countingPacketRouter = (CountingPacketRouter) router;
  assertEquals("Non matching message packet count", 4, countingPacketRouter.messageCount.get());
  assertFalse("User has devices but we are reporting he doesn't", result.noDevices());
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:34,代码来源:MessageDistributorImplTest.java

示例11: testDistribute2ToUserWithNoDevices

import org.xmpp.packet.Message; //导入方法依赖的package包/类
@Test
public void testDistribute2ToUserWithNoDevices() throws InterruptedException {
  MessageDistributor distributor = new StubMessageDistributorImpl();
  Message message = new Message();
  message.setBody("body");
  message.setSubject("subject");
  String toNode1 = "bud.worker";
  String fromNode = "thomas";
  String appKey = "AAABSNIBKOstQST7";
  String host = "mmx.magnet.com";
  String resource = "device1";
  message.setTo(new JID(toNode1 + JIDUtil.APP_ID_DELIMITER + appKey, host, null));
  message.setFrom(new JID(fromNode + JIDUtil.APP_ID_DELIMITER + appKey, host, resource));

  MessageDistributor.DistributionContext context = new DistributionContextImpl(toNode1, appKey, host, resource);

  PacketRouter router = new CountingPacketRouter();
  MMXPresenceFinder finder = new AlwaysOnlinePresenceFinder();
  ((StubMessageDistributorImpl) distributor).setPacketRouter(router);
  ((StubMessageDistributorImpl) distributor).setPresenceFinder(finder);

  MessageDistributor.DistributionResult result = distributor.distribute(message, context);

  try {
    Thread.sleep(5000);
  } catch (InterruptedException e) {
    System.out.println("testDistribute2ToUserWithNoDevices thread is interrupted");
  }

  CountingPacketRouter countingPacketRouter = (CountingPacketRouter) router;
  assertEquals("Non matching message packet count", 0, countingPacketRouter.messageCount.get());
  assertTrue("User has no devices but we are reporting he has", result.noDevices());
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:34,代码来源:MessageDistributorImplTest.java

示例12: test2Annotate

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Case where the incoming message has no mmxmeta
 * @throws Exception
 */
public void test2Annotate() throws Exception {

  String appId = "testapp1";
  String domain = "mmx";
  String user = "rahul";

  Message myMessage = new Message();
  myMessage.setType(Message.Type.chat);
  myMessage.setFrom(appId + "%" + appId + "@" + domain);
  myMessage.setTo(user + "%" + appId + "@" + domain);
  myMessage.setID("10");
  Element mmxElement = myMessage.addChildElement(Constants.MMX, Constants.MMX_NS_MSG_PAYLOAD);

  Element payloadElement = mmxElement.addElement(Constants.MMX_PAYLOAD);

  DateFormat fmt = Utils.buildISO8601DateFormat();
  String formattedDateTime = fmt.format(new Date());
  payloadElement.addAttribute(Constants.MMX_ATTR_STAMP, formattedDateTime);
  String text = ".";
  payloadElement.setText(text);
  payloadElement.addAttribute(Constants.MMX_ATTR_CHUNK, MessageBuilder.buildChunkAttributeValue(text));
  myMessage.setBody(MMXServerConstants.MESSAGE_BODY_DOT);

  MessageDistributedAnnotator messageDistributedAnnotator = new MessageDistributedAnnotator();
  messageDistributedAnnotator.annotate(myMessage);

  Element mmx = myMessage.getChildElement(Constants.MMX, Constants.MMX_NS_MSG_PAYLOAD);
  Element internalMeta = mmx.element(Constants.MMX_MMXMETA);
  String revisedJSON = internalMeta.getText();
  assertNotNull(revisedJSON);

  String expected = "{\"mmxdistributed\":true}";

  assertEquals("Non matching mmxmeta json", expected, revisedJSON);

}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:41,代码来源:MessageDistributedAnnotatorTest.java

示例13: test1IsAnnotated

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Test the case where we already have the distributed flag set.
 * @throws Exception
 */
public void test1IsAnnotated() throws Exception {

  String appId = "testapp1";
  String domain = "mmx";
  String user = "rahul";

  Message myMessage = new Message();
  myMessage.setType(Message.Type.chat);
  myMessage.setFrom(appId + "%" + appId + "@" + domain);
  myMessage.setTo(user + "%" + appId + "@" + domain);
  myMessage.setID("10");
  Element mmxElement = myMessage.addChildElement(Constants.MMX, Constants.MMX_NS_MSG_PAYLOAD);
  Element mmxMetaElement = mmxElement.addElement(Constants.MMX_MMXMETA);

  Map<String, String> mmxMetaMap = new HashMap<String, String>();
  mmxMetaMap.put("txId", "2010");
  mmxMetaMap.put("node", "test1_node");
  mmxMetaMap.put(MMXServerConstants.DISTRIBUTED_KEY, "false");

  String mmxMetaJSON = GsonData.getGson().toJson(mmxMetaMap);
  mmxMetaElement.setText(mmxMetaJSON);

  Element payloadElement = mmxElement.addElement(Constants.MMX_PAYLOAD);

  DateFormat fmt = Utils.buildISO8601DateFormat();
  String formattedDateTime = fmt.format(new Date());
  payloadElement.addAttribute(Constants.MMX_ATTR_STAMP, formattedDateTime);
  String text = ".";
  payloadElement.setText(text);
  payloadElement.addAttribute(Constants.MMX_ATTR_CHUNK, MessageBuilder.buildChunkAttributeValue(text));
  myMessage.setBody(MMXServerConstants.MESSAGE_BODY_DOT);

  MessageDistributedAnnotator messageDistributedAnnotator = new MessageDistributedAnnotator();
  messageDistributedAnnotator.annotate(myMessage);

  boolean isAnnotated = messageDistributedAnnotator.isAnnotated(myMessage);
  assertTrue("Message is not annotated", isAnnotated);
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:43,代码来源:MessageDistributedAnnotatorTest.java

示例14: createServerMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private Message createServerMessage(String subject, String body) {
    Message message = new Message();
    message.setTo(violationContact + "@"
            + violationNotificationFrom.getDomain());
    message.setFrom(violationNotificationFrom);
    message.setSubject(subject);
    message.setBody(body);
    return message;
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:10,代码来源:ContentFilterPlugin.java

示例15: 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


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