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


Java Message.setID方法代码示例

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


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

示例1: addWaveletUpdate

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Add a single wavelet-update message to the given Message. Should (probably)
 * not be called twice on the same Message.
 */
private Element addWaveletUpdate(Message updateMessage, boolean requestReceipt)
    throws EncodingException {
  updateMessage.setFrom(REMOTE_JID);
  updateMessage.setTo(LOCAL_JID);
  updateMessage.setID(TEST_ID);
  if (requestReceipt) {
    updateMessage.addChildElement("request", XmppNamespace.NAMESPACE_XMPP_RECEIPTS);
  }
  Element event = updateMessage.addChildElement("event", XmppNamespace.NAMESPACE_PUBSUB_EVENT);
  Element waveletUpdate =
      event.addElement("items").addElement("item").addElement("wavelet-update");
  waveletUpdate.addAttribute("wavelet-name",
      XmppUtil.waveletNameCodec.waveletNameToURI(REMOTE_WAVELET));
  return waveletUpdate;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:20,代码来源:XmppFederationRemoteTest.java

示例2: routeGeoEvent

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void routeGeoEvent(final IQ geoIQ) {
  if (componentJids.isEmpty()) {
    // nothing to do
    LOGGER.debug("no external component registered for geo event");
    return;
  }
  String geoService = selectGeoService();
  if (geoService != null && geoService.length() > 0) {
    Message geoMessage = buildGeoMessageFromPubSubIQ(geoIQ);
    if (geoMessage != null) {
      geoMessage.setTo(geoService);
      // TODO create a new message ID?
      geoMessage.setID(geoIQ.getID());
      LOGGER.debug("Sending geo event to external component: " + geoService);
      // start attaching the pieces
      PacketRouter router = XMPPServer.getInstance().getPacketRouter();
      router.route(geoMessage);
    }
  }
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:21,代码来源:GeoEventDispatcher.java

示例3: testDropInvalidResponseType

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Test that if (e.g.) an IQ is sent, then an IQ must be returned as a
 * response. If a Message is returned instead, this should invoke an error
 * callback.
 */
public void testDropInvalidResponseType() throws Exception {
  IQ packet = server1.manager.createRequestIQ(server2.jid);

  // Disable routing so we can intercept the packet.
  server1.transport.router = null;
  PacketCallback callback = mock(PacketCallback.class);
  server1.manager.send(packet, callback, PACKET_TIMEOUT);

  // Generate an explicit Message receipt.
  Message response = new Message();
  response.setTo(packet.getFrom());
  response.setID(packet.getID());
  response.setFrom(packet.getTo());
  response.addChildElement("received", XmppNamespace.NAMESPACE_XMPP_RECEIPTS);
  server1.manager.receivePacket(response);

  // Confirm that an error callback is invoked.
  ArgumentCaptor<FederationError> returnedError = ArgumentCaptor.forClass(FederationError.class);
  verify(callback).error(returnedError.capture());
  verify(callback, never()).run(any(Packet.class));
  assertEquals(FederationError.Code.UNDEFINED_CONDITION, returnedError.getValue().getErrorCode());

  // Confirm that sending a correct response now does nothing.
  reset(callback);
  IQ correctResponse = IQ.createResultIQ(packet);
  server1.manager.receivePacket(correctResponse);
  verifyZeroInteractions(callback);
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:34,代码来源:RoundTripTest.java

示例4: build

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Build an XMPP error message with MMX extension.
 * @return
 */
public Message build() {
  Message errorMsg = new Message();
  String appId = JIDUtil.getAppId(mOrigMsg.getFrom());
  errorMsg.setType(Type.error);
  errorMsg.setTo(mOrigMsg.getFrom());
  errorMsg.setFrom(appId + "%" + appId + "@" + XMPPServer.getInstance().getServerInfo().getXMPPDomain());
  errorMsg.setID(mOrigMsg.getID());
  errorMsg.addExtension(new MMXPacketExtension(mHeaders, mPayload));
  return errorMsg;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:15,代码来源:ErrorMessageBuilder.java

示例5: build

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
   * Build the ServerAckMessage
   * @return Message
   */
  public Message build() {

    JID sender = originalMessage.getFrom();
    String senderUserId = JIDUtil.getUserId(sender);
    String senderDeviceId = sender.getResource();

    Message ackMessage = new Message();
    ackMessage.setType(Message.Type.normal);    // unreliable signal message; don't need an ack
    ackMessage.setFrom(appId + "%" + appId + "@" + XMPPServer.getInstance().getServerInfo().getXMPPDomain());
    ackMessage.setTo(sender);
    ackMessage.setID(new MessageIdGeneratorImpl().generate(sender.toString(), appId, senderDeviceId));
    Element mmxElement = ackMessage.addChildElement(Constants.MMX, Constants.MMX_NS_MSG_SIGNAL);
    Element mmxMetaElement = mmxElement.addElement(Constants.MMX_MMXMETA);
    Map<String, ServerAckMmxMeta> mmxMetaMap = new HashMap<String, ServerAckMmxMeta>();
    ServerAckMmxMeta meta = new ServerAckMmxMeta();
    meta.setAckForMsgId(originalMessage.getID());
    if (type != Type.BATCH_BEGIN) {
      if (badReceivers == null) {
        // Don't allow null; use an empty list
        badReceivers = new ArrayList<MetaToEntry>(0);
      }
      meta.setBadReceivers(badReceivers);
    }
    meta.setErrorCode(errorCode);
    meta.setSender(senderUserId, senderDeviceId);
    mmxMetaMap.put(type.getValue(), meta);

    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);
//    payloadElement.addAttribute(Constants.MMX_ATTR_CHUNK, MessageBuilder.buildChunkAttributeValue(text));
//    ackMessage.setBody(MMXServerConstants.MESSAGE_BODY_DOT);
    return ackMessage;
  }
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:44,代码来源:ServerAckMessageBuilder.java

示例6: buildDeliveryReceipt

import org.xmpp.packet.Message; //导入方法依赖的package包/类
protected Message buildDeliveryReceipt(String appId, String incomingMessageFromJID, String incomingMessageToJID,
                                       String incomingMessageId) {
  MessageIdGenerator generator = new MessageIdGeneratorImpl();
  String id = generator.generate(incomingMessageFromJID, appId, null);
  Message receipt = new Message();
  receipt.setID(id);
  receipt.setFrom(incomingMessageToJID);
  receipt.setTo(incomingMessageFromJID);
  Element received = receipt.addChildElement(Constants.XMPP_RECEIVED, Constants.XMPP_NS_RECEIPTS);
  received.addAttribute(Constants.XMPP_ATTR_ID, incomingMessageId);
  return receipt;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:13,代码来源:BotRegistrationImpl.java

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

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

示例9: generateSendMessageStanza

import org.xmpp.packet.Message; //导入方法依赖的package包/类
static String generateSendMessageStanza() {
  String fromJid = "%%_username%%@"+genSettings.servername+"/tsung";
  String toJid = "%%_tojid%%@"+genSettings.servername+"/tsung";
  Message message = new Message();
  message.setType(Type.chat);
  message.getElement().addAttribute("from", fromJid);
  message.getElement().addAttribute("to", toJid);
  message.setID("%%ts_user_server:get_unique_id%%");

  // build up the MMX message packet extension
  Element element = message.addChildElement(Constants.MMX, Constants.MMX_NS_MSG_PAYLOAD);
  element.addElement(Constants.MMX_META);
  Element payload = element.addElement(Constants.MMX_PAYLOAD);
  payload.addAttribute(Constants.MMX_ATTR_CTYPE, "plain/text");
  payload.addAttribute(Constants.MMX_ATTR_MTYPE, "string");
  String randomText = "Considered an invitation do introduced sufficient understood instrument it. Of decisively friendship in as collecting at. No affixed be husband ye females brother garrets proceed. Least child who seven happy yet balls young. Discovery sweetness principle discourse shameless bed one excellent. Sentiments of surrounded friendship dispatched connection is he. Me or produce besides hastily up as pleased. Bore less when had and john shed hope. \n" +
      "\n" +
      "Barton waited twenty always repair in within we do. An delighted offending curiosity my is dashwoods at. Boy prosperous increasing surrounded companions her nor advantages sufficient put. John on time down give meet help as of. Him waiting and correct believe now cottage she another. Vexed six shy yet along learn maids her tiled. Through studied shyness evening bed him winding present. Become excuse hardly on my thirty it wanted. \n" +
      "\n" +
      "Six reached suppose our whether. Oh really by an manner sister so. One sportsman tolerably him extensive put she immediate. He abroad of cannot looked in. Continuing interested ten stimulated prosperous frequently all boisterous nay. Of oh really he extent horses wicket. \n" +
      "\n" +
      "Placing assured be if removed it besides on. Far shed each high read are men over day. Afraid we praise lively he suffer family estate is. Ample order up in of in ready. Timed blind had now those ought set often which. Or snug dull he show more true wish. No at many deny away miss evil. On in so indeed spirit an mother. Amounted old strictly but marianne admitted. People former is remove remain as. \n" +
      "\n" +
      "Little afraid its eat looked now. Very ye lady girl them good me make. It hardly cousin me always. An shortly village is raising we shewing replied. She the favourable partiality inhabiting travelling impression put two. His six are entreaties instrument acceptance unsatiable her. Amongst as or on herself chapter entered carried no. Sold old ten are quit lose deal his sent. You correct how sex several far distant believe journey parties. We shyness enquire uncivil affixed it carried to. \n" +
      "\n" +
      "Parish so enable innate in formed missed. Hand two was eat busy fail. Stand smart grave would in so. Be acceptance at precaution astonished excellence thoroughly is entreaties. Who decisively attachment has dispatched. Fruit defer in party me built under first. Forbade him but savings sending ham general. So play do in near park that pain. \n" +
      "\n" +
      "Needed feebly dining oh talked wisdom oppose at. Applauded use attempted strangers now are middleton concluded had. It is tried \uFEFFno added purse shall no on truth. Pleased anxious or as in by viewing forbade minutes prevent. Too leave had those get being led weeks blind. Had men rose from down lady able. Its son him ferrars proceed six parlors. Her say projection age announcing decisively men. Few gay sir those green men timed downs widow chief. Prevailed remainder may propriety can and. \n" +
      "\n" +
      "Seen you eyes son show. Far two unaffected one alteration apartments celebrated but middletons interested. Described deficient applauded consisted my me do. Passed edward two talent effect seemed engage six. On ye great do child sorry lived. Proceed cottage far letters ashamed get clothes day. Stairs regret at if matter to. On as needed almost at basket remain. By improved sensible servants children striking in surprise. \n" +
      "\n" +
      "Rendered her for put improved concerns his. Ladies bed wisdom theirs mrs men months set. Everything so dispatched as it increasing pianoforte. Hearing now saw perhaps minutes herself his. Of instantly excellent therefore difficult he northward. Joy green but least marry rapid quiet but. Way devonshire introduced expression saw travelling affronting. Her and effects affixed pretend account ten natural. Need eat week even yet that. Incommode delighted he resolving sportsmen do in listening. \n" +
      "\n" +
      "On recommend tolerably my belonging or am. Mutual has cannot beauty indeed now sussex merely you. It possible no husbands jennings ye offended packages pleasant he. Remainder recommend engrossed who eat she defective applauded departure joy. Get dissimilar not introduced day her apartments. Fully as taste he mr do smile abode every. Luckily offered article led lasting country minutes nor old. Happen people things oh is oppose up parish effect. Law handsome old outweigh humoured far appetite. \n" +
      "\n";
  payload.addText(StringEscapeUtils.escapeXml(randomText));
  return message.toXML().toString();
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:39,代码来源:GenTestScript.java

示例10: broadcast

import org.xmpp.packet.Message; //导入方法依赖的package包/类
@Override
public void broadcast(Node node, Message message, Collection<JID> jids) {
    // TODO Possibly use a thread pool for sending packets (based on the jids size)
    message.setFrom(getAddress());
    for (JID jid : jids) {
        message.setTo(jid);
        message.setID(StringUtils.randomString(8));
        router.route(message);
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:11,代码来源:PubSubModule.java

示例11: sendNotification

import org.xmpp.packet.Message; //导入方法依赖的package包/类
@Override
public void sendNotification(Node node, Message message, JID jid) {
    message.setFrom(getAddress());
    message.setTo(jid);
    message.setID(StringUtils.randomString(8));
    router.route(message);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:8,代码来源:PubSubModule.java

示例12: broadcast

import org.xmpp.packet.Message; //导入方法依赖的package包/类
@Override
public void broadcast(Node node, Message message, Collection<JID> jids) {
    message.setFrom(getAddress());
    for (JID jid : jids) {
        message.setTo(jid);
        message.setID(StringUtils.randomString(8));
        router.route(message);
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:10,代码来源:PEPService.java

示例13: processMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
@Override
protected void processMessage(Message packet) throws UnauthorizedException {
    if (session.getStatus() != Session.STATUS_AUTHENTICATED) {
        // Session is not authenticated so return error
        Message reply = new Message();
        reply.setID(packet.getID());
        reply.setTo(packet.getFrom());
        reply.setFrom(packet.getTo());
        reply.setError(PacketError.Condition.not_authorized);
        session.process(reply);
        return;
    }
    super.processMessage(packet);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:15,代码来源:ComponentStanzaHandler.java

示例14: generateCommand

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Generates a basic ad-hoc command with From,To, Type, ID & Body configured. Body might need to be reconfigured
 * when additional info has to be specified, like unregister
 * 
 * @param transport
 * @param command
 * @return
 */
private Message generateCommand(String transport, String command) {
    Message message = new Message();
    message.setFrom(adminUser);
    message.setTo(transport);
    message.setID(command);
    message.setBody(command);
    message.setType(Type.chat);
    return message;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:18,代码来源:GojaraAdminManager.java

示例15: broadcast

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void broadcast(Node node, Message message, Collection<JID> jids) {
    // TODO Possibly use a thread pool for sending packets (based on the jids size)
    message.setFrom(getAddress());
    for (JID jid : jids) {
        message.setTo(jid);
        message.setID(
                node.getNodeID() + "__" + jid.toBareJID() + "__" + StringUtils.randomString(5));
        router.route(message);
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:11,代码来源:PubSubModule.java


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