Package org.xmpp.packet

Examples of org.xmpp.packet.Message


    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());
View Full Code Here


   * Tests an update message containing both a delta and commit notice from a
   * foreign federation host is correctly decoded and passed to the Update
   * Listener Factory, and a response is sent as requested.
   */
  public void testUpdate() throws EncodingException {
    Message updateMessage = new Message();
    Element waveletUpdate = addWaveletUpdate(updateMessage, true); // request receipt
    waveletUpdate.addElement("applied-delta").addCDATA(Base64Util.encode(DELTA_BYTESTRING));
    waveletUpdate.addElement("commit-notice")
        .addAttribute("version", String.valueOf(VERSION_ONE.getVersion()))
        .addAttribute("history-hash", Base64Util.encode(VERSION_ONE.getHistoryHash()));
View Full Code Here

  /**
   * Test that a single update message, where a receipt is not requested, is
   * correctly received and processed.
   */
  public void testUpdateNoReceipt() throws EncodingException {
    Message updateMessage = new Message();
    Element waveletUpdate = addWaveletUpdate(updateMessage, false);
    waveletUpdate.addElement("applied-delta").addCDATA(Base64Util.encode(DELTA_BYTESTRING));

    manager.receivePacket(updateMessage);

View Full Code Here

   *
   * @param request the request message
   * @return the new response message
   */
  public static Message createResponseMessage(Message request) {
    Message response = new Message();
    response.setID(request.getID());
    response.setTo(request.getFrom());
    response.setFrom(request.getTo());
    return response;
  }
View Full Code Here

        response(packet);
      } else {
        processIqGetSet(iq);
      }
    } else if (packet instanceof Message) {
      Message message = (Message) packet;
      if (message.getType().equals(Message.Type.error)
          || message.getChildElement("received", XmppNamespace.NAMESPACE_XMPP_RECEIPTS) != null) {
        // Response type, hand off to callback handler.
        response(packet);
      } else {
        processMessage(message);
      }
View Full Code Here

   *
   * @param toJid target JID
   * @return new Message stanza
   */
  public Message createRequestMessage(String toJid) {
    return createRequest(new Message(), toJid);
  }
View Full Code Here

    if (message.getChildElement("event", XmppNamespace.NAMESPACE_PUBSUB_EVENT) != null) {
      remote.update(message, new IncomingCallback(message));
    } else if (message.getChildElement("ping", XmppNamespace.NAMESPACE_WAVE_SERVER) != null) {
      // Respond inline to the ping.
      LOG.info("Responding to ping from: " + message.getFrom());
      Message response = XmppUtil.createResponseMessage(message);
      response.addChildElement("received", XmppNamespace.NAMESPACE_XMPP_RECEIPTS);
      transport.sendPacket(response);
    } else {
      sendErrorResponse(message, FederationError.Code.BAD_REQUEST, "Unhandled message type");
    }
  }
View Full Code Here

      IQ.Type type = ((IQ) request).getType();
      if (!(type.equals(IQ.Type.get) ||  type.equals(IQ.Type.set))) {
        throw new IllegalArgumentException("May only return an error to IQ get/set, not: " + type);
      }
    } else if (request instanceof Message) {
      Message message = (Message) request;
      if (message.getType().equals(Message.Type.error)) {
        throw new IllegalArgumentException("Can't return an error to another message error");
      }
    } else {
      throw new IllegalArgumentException("Unexpected Packet subclass, expected Message/IQ: "
          + request.getClass());
View Full Code Here

   * @param remoteJid        the remote JID to send the update to
   */
  private void internalWaveletUpdate(final WaveletName waveletName,
      final List<ByteString> deltaList, final ProtocolHashedVersion committedVersion,
      final WaveletUpdateCallback callback, String remoteJid) {
    Message message = new Message();
    message.setType(Message.Type.normal);
    message.setFrom(jid);
    message.setTo(remoteJid);
    message.setID(XmppUtil.generateUniqueId());
    message.addChildElement("request", XmppNamespace.NAMESPACE_XMPP_RECEIPTS);

    final String encodedWaveletName;
    try {
      encodedWaveletName = XmppUtil.waveletNameCodec.waveletNameToURI(waveletName);
    } catch (EncodingException e) {
      callback.onFailure(FederationErrors.badRequest("Bad wavelet name " + waveletName));
      return;
    }

    Element itemElement = message.addChildElement("event", XmppNamespace.NAMESPACE_PUBSUB_EVENT)
        .addElement("items").addElement("item");
    if (deltaList != null) {
      for (ByteString delta : deltaList) {
        Element waveletUpdate =
            itemElement.addElement("wavelet-update", XmppNamespace.NAMESPACE_WAVE_SERVER)
View Full Code Here

    final AtomicInteger callbackCount = new AtomicInteger(1);
    final Runnable countDown = new Runnable() {
      @Override
      public void run() {
        if (callbackCount.decrementAndGet() == 0 && receiptRequested != null) {
          Message response = XmppUtil.createResponseMessage(updateMessage);
          response.addChildElement("received", XmppNamespace.NAMESPACE_XMPP_RECEIPTS);
          responseCallback.run(response);
        }
      }
    };
View Full Code Here

TOP

Related Classes of org.xmpp.packet.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.