Package org.xmpp.packet

Examples of org.xmpp.packet.Packet


  /**
   * Checks the update message is as expected.
   */
  private void checkUpdateMessage() {
    assertEquals(1, transport.packetsSent);
    Packet packet = transport.lastPacketSent;
    assertEquals(REMOTE_JID, packet.getTo().toString());
    assertEquals(LOCAL_JID, packet.getFrom().toString());
    assertEquals(EXPECTED_UPDATE_MESSAGE, packet.toString());
  }
View Full Code Here


  /**
   * Checks an update and then a commit message were sent.
   */
  private void checkUpdateAndCommit() {
    assertEquals(2, transport.packetsSent);
    Packet packet = transport.packets.poll();
    assertEquals(REMOTE_JID, packet.getTo().toString());
    assertEquals(LOCAL_JID, packet.getFrom().toString());
    assertEquals(EXPECTED_UPDATE_MESSAGE, packet.toString());

    packet = transport.packets.poll();
    assertEquals(REMOTE_JID, packet.getTo().toString());
    assertEquals(LOCAL_JID, packet.getFrom().toString());
    assertEquals(generateExpectedCommitMessage("2" + TEST_ID_SUFFIX), packet.toString());
  }
View Full Code Here

   */
  public void testDiscoStart() {
    XmppUtil.fakeUniqueId = DISCO_ITEMS_ID;
    disco.discoverRemoteJid(REMOTE_DOMAIN, discoCallback);
    assertEquals(1, transport.packets.size());
    Packet packet = transport.packets.poll();
    assertEquals(REMOTE_DOMAIN, packet.getTo().toString());
    assertEquals(LOCAL_JID, packet.getFrom().toString());
    assertEquals(EXPECTED_DISCO_ITEMS_GET, packet.toString());
    checkAndResetStats(1, 0, 0)// started
  }
View Full Code Here

  public void testDiscoNoRetransmitsAfterReply() throws ExecutionException {
    XmppUtil.fakeUniqueId = DISCO_ITEMS_ID;
    disco.discoverRemoteJid(REMOTE_DOMAIN, discoCallback);
    checkAndResetStats(1, 0, 0)// started
    assertEquals("Expected disco packet to be sent", 1, transport.packetsSent);
    Packet packet = transport.lastPacketSent;
    assertEquals(EXPECTED_DISCO_ITEMS_GET, packet.toString());
    assertTrue(disco.isDiscoRequestPending(REMOTE_DOMAIN));

    IQ discoItemsResult = createDiscoItems(true /* wave */, false /* not pubsub */);
    discoItemsResult.setID(packet.getID());
    XmppUtil.fakeUniqueId = DISCO_INFO_ID;
    manager.receivePacket(discoItemsResult);
    assertEquals("Expected disco info get to be sent", 2, transport.packetsSent);
    assertEquals(EXPECTED_DISCO_INFO_GET, transport.lastPacketSent.toString());

View Full Code Here

    IQ discoItemsResult = createDiscoItems(true /* wave */, false /* not pubsub */);

    XmppUtil.fakeUniqueId = DISCO_INFO_ID;
    manager.receivePacket(discoItemsResult);
    assertEquals(2, transport.packetsSent);
    Packet packet = transport.lastPacketSent;
    assertEquals(REMOTE_JID, packet.getTo().toString());
    assertEquals(LOCAL_JID, packet.getFrom().toString());
    assertEquals(EXPECTED_DISCO_INFO_GET, packet.toString());
    checkAndResetStats(0, 0, 0)// no additional varz
  }
View Full Code Here

    IQ discoItemsResult = createDiscoItems(true /* wave */, false /* not pubsub */);
    // Start the process.
    XmppUtil.fakeUniqueId = DISCO_INFO_ID;
    manager.receivePacket(discoItemsResult);
    assertEquals(2, transport.packetsSent);
    Packet packet = transport.lastPacketSent;
    assertEquals(EXPECTED_DISCO_INFO_GET, packet.toString());
    // create a wave disco result, inject into disco.
    manager.receivePacket(createDiscoInfo(true /* wave */));
    assertEquals(2, transport.packetsSent);
    verify(discoCallback).onSuccess(eq(REMOTE_JID));
    checkAndResetStats(0, 1, 0)// success
View Full Code Here

    LOG.fine("Sending error condition in response to " + request.getID() + ": "
        + error.getCondition().name());

    // Note that this does not include the original packet; just the ID.
    final Packet response = XmppUtil.createResponsePacket(request);
    response.setError(error);

    transport.sendPacket(response);
  }
View Full Code Here

    }

    public void route(Packet packet) {
        Set<String> remoteServers = new HashSet<String>();
        List<String> targets = new ArrayList<String>();
        Packet localBroadcast = packet.createCopy();
        Element addresses = getAddresses(localBroadcast);
        String localDomain = "@" + server.getServerInfo().getXMPPDomain();
        // Build the <addresses> element to be included for local users and identify
        // remote domains that should receive the packet too
        for (Iterator it=addresses.elementIterator("address");it.hasNext();) {
            Element address = (Element) it.next();
            // Skip addresses of type noreply since they don't have any address
            if (Type.noreply.toString().equals(address.attributeValue("type"))) {
                continue;
            }
            String jid = address.attributeValue("jid");
            // Only send to local users and if packet has not already been delivered
            if (jid.contains(localDomain) && address.attributeValue("delivered") == null) {
                targets.add(jid);
            }
            else if (!jid.contains(localDomain)) {
                remoteServers.add(new JID(jid).getDomain());
            }
            // Set as delivered
            address.addAttribute("delivered", "true");
            // Remove bcc addresses
            if (Type.bcc.toString().equals(address.attributeValue("type"))) {
                it.remove();
            }
        }
        // Send the packet to local target users
        for (String jid : targets) {
            localBroadcast.setTo(jid);
            packetRouter.route(localBroadcast);
        }

        // Keep a registry of packets that should be sent to remote domains.
        for (String domain : remoteServers) {
View Full Code Here

                    RosterItem item = roster.getRosterItem(senderJID);
                    roster.deleteRosterItem(senderJID, true);
                    item.setSubStatus(RosterItem.SUB_REMOVE);
                    item.setSubStatus(RosterItem.SUB_NONE);

                    Packet itemPacket = packet.createCopy();
                    sessionManager.userBroadcast(recipientJID.getNode(), itemPacket);
                }
            }
        }
        catch (UserNotFoundException e) {
View Full Code Here

            // Check if the recipient may be hosted by this server
            if (!recipient.getDomain().contains(serverDomain)) {
                // TODO Implete when s2s is implemented
            }
            else {
                Packet removePacket = createRemoveForward(sender, recipient);
                router.route(removePacket);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.xmpp.packet.Packet

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.