org.jivesoftware.smack.packet.Message.addBody()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(179)

本文整理了Java中org.jivesoftware.smack.packet.Message.addBody()方法的一些代码示例,展示了Message.addBody()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.addBody()方法的具体详情如下:
包路径:org.jivesoftware.smack.packet.Message
类名称:Message
方法名:addBody

Message.addBody介绍

[英]Adds a body with a corresponding language.
[中]

代码示例

代码示例来源:origin: igniterealtime/Smack

  1. /**
  2. * Sets the body of the message. The body is the main message contents.
  3. *
  4. * @param body the body of the message.
  5. */
  6. public void setBody(String body) {
  7. if (body == null) {
  8. removeBody(""); // use empty string because #removeBody(null) is ambiguous
  9. return;
  10. }
  11. addBody(null, body);
  12. }

代码示例来源:origin: igniterealtime/Smack

  1. @Test(expected = NullPointerException.class)
  2. public void setNullMessageBodyTest() {
  3. Message message = getNewMessage();
  4. message.addBody(null, null);
  5. }

代码示例来源:origin: igniterealtime/Smack

  1. message.addBody(null, messageBody1);
  2. message.addBody(lang2, messageBody2);
  3. message.addBody(lang3, messageBody3);
  4. XmlUnitUtils.assertSimilar(control, message.toXML(StreamOpen.CLIENT_NAMESPACE));

代码示例来源:origin: igniterealtime/Smack

  1. @Test
  2. public void removeMessageBodyTest() {
  3. Message message = getNewMessage();
  4. message.setBody("test");
  5. assertTrue(message.getBodies().size() == 1);
  6. message.setBody(null);
  7. assertTrue(message.getBodies().size() == 0);
  8. assertFalse(message.removeBody("sp"));
  9. Message.Body body = message.addBody("es", "test");
  10. assertTrue(message.getBodies().size() == 1);
  11. message.removeBody(body);
  12. assertTrue(message.getBodies().size() == 0);
  13. }

代码示例来源:origin: stackoverflow.com

  1. if(msg.getBody().toString().equalsIgnoreCase("RecivedByReciver")){
  2. //do what you want after get notify.
  3. }else{
  4. //do what you want if not delevery report message.
  5. Message message=new Message(ConnectionManager.parseBareAddress(msg.getFrom()),Message.Type.chat);
  6. message.addBody(null,"RecivedByReciver");
  7. Connection().sendPacket(message);
  8. }

代码示例来源:origin: org.igniterealtime.smack/smack

  1. /**
  2. * Sets the body of the message. The body is the main message contents.
  3. *
  4. * @param body the body of the message.
  5. */
  6. public void setBody(String body) {
  7. if (body == null) {
  8. removeBody(""); // use empty string because #removeBody(null) is ambiguous
  9. return;
  10. }
  11. addBody(null, body);
  12. }

代码示例来源:origin: tiandawu/IotXmpp

  1. /**
  2. * Sets the body of the message. The body is the main message contents.
  3. *
  4. * @param body the body of the message.
  5. */
  6. public void setBody(String body) {
  7. if (body == null) {
  8. removeBody(""); // use empty string because #removeBody(null) is ambiguous
  9. return;
  10. }
  11. addBody(null, body);
  12. }

代码示例来源:origin: org.igniterealtime.smack/smack-core

  1. /**
  2. * Sets the body of the message. The body is the main message contents.
  3. *
  4. * @param body the body of the message.
  5. */
  6. public void setBody(String body) {
  7. if (body == null) {
  8. removeBody(""); // use empty string because #removeBody(null) is ambiguous
  9. return;
  10. }
  11. addBody(null, body);
  12. }

代码示例来源:origin: org.littleshoot/smack-xmpp-3-2-2

  1. /**
  2. * Sets the body of the message. The body is the main message contents.
  3. *
  4. * @param body the body of the message.
  5. */
  6. public void setBody(String body) {
  7. if (body == null) {
  8. removeBody(""); // use empty string because #removeBody(null) is ambiguous
  9. return;
  10. }
  11. addBody(null, body);
  12. }

代码示例来源:origin: Blazemeter/jmeter-bzm-plugins

  1. private void sendResponseMessage(Message inMsg) {
  2. Message outMsg = new Message(inMsg.getFrom());
  3. outMsg.setType(inMsg.getType());
  4. outMsg.addBody("", inMsg.getBody() + "\r\n" + System.currentTimeMillis() + "@" + RESPONSE_MARKER);
  5. log.debug("Responding to message: " + outMsg.toXML());
  6. try {
  7. conn.sendPacket(outMsg);
  8. } catch (SmackException e) {
  9. log.error("Failed to send response", e);
  10. }
  11. }

代码示例来源:origin: tiandawu/IotXmpp

  1. message.addBody(xmlLang, body);

代码示例来源:origin: org.igniterealtime.smack/smack

  1. message.addBody(xmlLang, body);

代码示例来源:origin: org.littleshoot/smack-xmpp-3-2-2

  1. message.addBody(xmlLang, body);

代码示例来源:origin: Blazemeter/jmeter-bzm-plugins

  1. @Override
  2. public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
  3. // sending message
  4. String recipient = sampler.getPropertyAsString(RECIPIENT);
  5. String body = sampler.getPropertyAsString(BODY);
  6. boolean wait_response = sampler.getPropertyAsBoolean(WAIT_RESPONSE);
  7. if (wait_response) {
  8. body += "\r\n" + System.currentTimeMillis() + "@" + NEED_RESPONSE_MARKER;
  9. }
  10. Message msg = new Message(recipient);
  11. msg.setType(Message.Type.fromString(sampler.getPropertyAsString(TYPE, Message.Type.normal.toString())));
  12. msg.addBody("", body);
  13. res.setSamplerData(msg.toXML().toString());
  14. sampler.getXMPPConnection().sendPacket(msg);
  15. res.setSamplerData(msg.toXML().toString()); // second time to reflect the changes made to packet by conn
  16. if (wait_response) {
  17. return waitResponse(res, recipient);
  18. }
  19. return res;
  20. }

相关文章