Package org.jivesoftware.smack

Examples of org.jivesoftware.smack.PacketCollector


      //TODO:gs may put in other thread???
      SessionCount response;
      try {
        IQ packet = new SessionCount();
        packet.setFrom(con.getUser());
        PacketCollector collector = con.createPacketCollector(new PacketIDFilter(packet.getPacketID()));
        con.sendPacket(packet);
        response = (SessionCount) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
        collector.cancel();
        if (response == null) {
          log.warn("Error while trying to count sessions at IM server. Response was null!");
          return sessionCount;
        }
        if (response.getError() != null) {
View Full Code Here


 
  private IQ sendPacket(IQ packet) {
    XMPPConnection con = adminUser.getConnection();
    try {
      packet.setFrom(con.getUser());
      PacketCollector collector = con.createPacketCollector(new PacketIDFilter(packet.getPacketID()));
      con.sendPacket(packet);
      IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
      collector.cancel();
     
      if (response == null) {
        log.error("Error while trying to get all sessions IM server. Response was null!");
        return null;
      }
View Full Code Here

    if (con != null && con.isConnected()) {
      PluginVersion response;
      try {
        IQ packet = new PluginVersion();
        packet.setFrom(con.getUser());
        PacketCollector collector = con.createPacketCollector(new PacketIDFilter(packet.getPacketID()));
        //TODO:gs is sending packets over one connection thread save?
        con.sendPacket(packet);
        response = (PluginVersion) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
        collector.cancel();
        if (response == null) {
          log.error("Error while trying to get version at IM server. Response was null!");
          return version;
        }
        if (response.getError() != null) {
View Full Code Here

        return client;
    }

    protected Packet sendSync(XMPPConnection client, Packet request) {
        // Create a packet collector to listen for a response.
        PacketCollector collector = client.createPacketCollector(
                       new PacketIDFilter(request.getPacketID()));

        client.sendPacket(request);
       
        // Wait up to 5 seconds for a result.
        return collector.nextResult(5000);
    }
View Full Code Here

        return client;
    }

    protected Packet sendSync(XMPPConnection client, Packet request) {
        // Create a packet collector to listen for a response.
        PacketCollector collector = client.createPacketCollector(new PacketIDFilter(request.getPacketID()));

        client.sendPacket(request);

        // Wait up to 5 seconds for a result.
        return collector.nextResult(5000);
    }
View Full Code Here

        return client;
    }

    protected Packet sendSync(XMPPConnection client, Packet request) {
        // Create a packet collector to listen for a response.
        PacketCollector collector = client.createPacketCollector(new PacketIDFilter(request.getPacketID()));

        client.sendPacket(request);

        // Wait up to 5 seconds for a result.
        return collector.nextResult(5000);
    }
View Full Code Here

    @Override
    protected void onReceiveBeforeRead() throws IOException {
        PacketFilter packetFilter = createPacketFilter();

        PacketCollector collector = connection.createPacketCollector(packetFilter);
        Packet packet = receiveTimeout >= 0 ? collector.nextResult(receiveTimeout) : collector.nextResult();
        if (packet instanceof Message) {
            responseMessage = (Message) packet;
        }
        else if (packet != null) {
            throw new IllegalArgumentException(
View Full Code Here

            System.out.print("Looking for " + readerAddress + "...");
            while (true) {
                IQ testIQ = new Time();
                testIQ.setType(IQ.Type.GET);
                testIQ.setTo(readerAddress);
                PacketCollector collector = con.createPacketCollector(new PacketIDFilter(testIQ.getPacketID()));
                con.sendPacket(testIQ);
                // Wait 5 seconds.
                long start = System.currentTimeMillis();
                Packet result = collector.nextResult(5000);
                collector.cancel();
                // If we got a result, continue.
                if (result != null && result.getError() == null) {
                    System.out.println(" found reader. Starting packet flood.");
                    break;
                }
View Full Code Here

        doLoad(connection, user);
    }

    private void doLoad(XMPPConnection connection, String user) throws XMPPException {
        setType(Type.GET);
        PacketCollector collector = connection.createPacketCollector(
                new PacketIDFilter(getPacketID()));
        connection.sendPacket(this);

        VCard result = null;
        try {
            result = (VCard) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

            if (result == null) {
                throw new XMPPException(new XMPPError(408, "Timeout getting VCard information"));
            }
            if (result.getError() != null) {
View Full Code Here

   
    public static BrowseIQ retrieveBrowseRequest(XMPPConnection conn, String to) throws XMPPException {
      BrowseIQ iq = new BrowseIQ();
      iq.setType(IQ.Type.GET);
      iq.setTo(to);
          PacketCollector collector =
              conn.createPacketCollector(new PacketIDFilter(iq.getPacketID()));

          conn.sendPacket(iq);

          // Wait up to 5 seconds for a result.
          IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
          // Stop queuing results
          collector.cancel();
          if (result == null) {
              throw new XMPPException("No response from the server.");
          }
          if (result.getType() == IQ.Type.ERROR) {
              throw new XMPPException(result.getError());
View Full Code Here

TOP

Related Classes of org.jivesoftware.smack.PacketCollector

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.