Package org.jivesoftware.smack

Examples of org.jivesoftware.smack.PacketCollector


        Version request = new Version();
        request.setType(IQ.Type.GET);
        request.setTo(dialog.getUser());

        // Create a packet collector to listen for a response.
        PacketCollector collector = con
                .createPacketCollector(new PacketIDFilter(request.getPacketID()));

        con.sendPacket(request);

        // Wait up to 5 seconds for a result.
        IQ result = (IQ) collector.nextResult(SmackConfiguration
                .getPacketReplyTimeout());
        if( dialog.cancelled ) return;

        if (result != null && result.getType() == IQ.Type.RESULT) {
            Version v = (Version) result;
View Full Code Here


        Time request = new Time();
        request.setType(IQ.Type.GET);
        request.setTo(dialog.getUser());

        // Create a packet collector to listen for a response.
        PacketCollector collector = con
                .createPacketCollector(new PacketIDFilter(request.getPacketID()));

        con.sendPacket(request);


        // Wait up to 5 seconds for a result.
        IQ result = (IQ) collector.nextResult(SmackConfiguration
                .getPacketReplyTimeout());
        collector.cancel();
        if( dialog.cancelled ) return;

        if (result != null && result.getType() == IQ.Type.RESULT) {
            Time t = (Time) result;
View Full Code Here

        LastActivity request = new LastActivity();
        request.setType(IQ.Type.GET);
        request.setTo(dialog.getUser());

        // Create a packet collector to listen for a response.
        PacketCollector collector = con
                .createPacketCollector(new PacketIDFilter(request.getPacketID()));

        con.sendPacket(request);

        // Wait up to 5 seconds for a result.
        IQ result = (IQ) collector.nextResult(SmackConfiguration
                .getPacketReplyTimeout());
        if( dialog.cancelled ) return;

        if (result != null && result.getType() == IQ.Type.RESULT) {
            LastActivity t = (LastActivity) result;
View Full Code Here

        sendPacket(srch);

        PacketFilter filter = new AndFilter(new PacketIDFilter(srch.getPacketID()),
            new PacketTypeFilter(IQ.class));
        PacketCollector packetCollector =
            BuddyList.getInstance().getConnection().createPacketCollector(filter);

        final IQ reply = (IQ) packetCollector.nextResult(SmackConfiguration.getPacketReplyTimeout());
        if(reply == null)
        {
            SwingUtilities.invokeLater( new Runnable()
            {
                public void run()
                {
                    wait.setVisible( false );
                    JOptionPane.showMessageDialog(SearchDialog.this,
                        resources.getString("searchRequestTimeout"),
                        resources.getString("searchError"),
                        JOptionPane.OK_OPTION);
                }
            });
        }
        else
        {
            SwingUtilities.invokeLater(new Runnable()
            {
                public void run()
                {
                    wait.setVisible( false );
                   if( cancelled ) { return; }

                    // update results table with new data
                    resultsTableModel.setItems(((Search) reply).getItems());
                    resultsTableModel.fireTableStructureChanged();
                    resultsTableModel.fireTableDataChanged();
                }
            });
        }
        packetCollector.cancel();
    }
View Full Code Here

        sendPacket(searchQuery);

        PacketFilter filter = new AndFilter(new PacketIDFilter(searchQuery.getPacketID()),
            new PacketTypeFilter(IQ.class));

        PacketCollector packetCollector =
            BuddyList.getInstance().getConnection().createPacketCollector(filter);

        IQ reply = (IQ) packetCollector.nextResult(SmackConfiguration.getPacketReplyTimeout());
        if(reply == null)
        {
            SwingUtilities.invokeLater( new Runnable()
            {
                public void run()
                {
                    JOptionPane.showMessageDialog(SearchDialog.this,
                        resources.getString("searchRequestTimeout"),
                        resources.getString("searchError"),
                        JOptionPane.OK_OPTION);
                }
            } );
            returnVal = false;
        }
        else
        {
            if(reply.getType() == IQ.Type.ERROR)
            {
                SwingUtilities.invokeLater( new Runnable()
                {
                    public void run()
                    {
                        JOptionPane.showMessageDialog(SearchDialog.this,
                            resources.getString("serviceDoesNotSupportJaberSearch"),
                            resources.getString("searchError"),
                            JOptionPane.OK_OPTION
                            );
                        wait.setVisible(false);
                    }
                });

                returnVal = false;
            }
            else if(reply instanceof Search)
            {
                search = (Search) reply;
                returnVal = true;
            }
        }
        packetCollector.cancel();
        return returnVal;
    }
View Full Code Here

            // send the packet
            register.setAttributes(map);
            PacketFilter filter = new AndFilter(new PacketIDFilter(register
                    .getPacketID()), new PacketTypeFilter(IQ.class));

            PacketCollector collector = BuddyList.getInstance().getConnection()
                    .createPacketCollector(filter);
            BuddyList.getInstance().getConnection().sendPacket(register);

            // collect the response
            IQ result = (IQ) collector.nextResult(SmackConfiguration
                    .getPacketReplyTimeout());
            wait.dispose();

            if (stopped)
                return;
View Full Code Here

            register.setType(IQ.Type.GET);
            register.setTo(server);
            PacketFilter filter = new AndFilter(new PacketIDFilter(register
                    .getPacketID()), new PacketTypeFilter(IQ.class));

            PacketCollector collector = BuddyList.getInstance().getConnection()
                    .createPacketCollector(filter);

            // send the request
            BuddyList.getInstance().getConnection().sendPacket(register);

            // collect the response
            IQ result = (IQ) collector.nextResult(SmackConfiguration
                    .getPacketReplyTimeout());

            if (stopped)
                return;
View Full Code Here

      Thread.sleep(1000);
      long start = System.currentTimeMillis();
      for (Iterator iterator = packets.iterator(); iterator.hasNext();) {
        IQ iqPacket = (IQ) iterator.next();
        iqPacket.setFrom(connection.getUser());
        PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(iqPacket.getPacketID()));
        connection.sendPacket(iqPacket);
        IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
        collector.cancel();
       
        if (response == null) {
          throw new XMPPException("No response from server on status set.");
        }
        if (response.getError() != null) {
View Full Code Here

 
  private boolean 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) {
        // OLAT-5383: error happens frequently, lowering to WARN
        log.warn("Error while trying to create/delete user at IM server. Response was null!");
        return false;
View Full Code Here

 
  private boolean 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 create/delete group at IM server. Response was null! packet type: "+packet.getClass());
        return false;
      }
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.