Package org.jivesoftware.smack

Examples of org.jivesoftware.smack.XMPPConnection


      String password = usernamePrefix + (connectionIndex + 1);
     
      if (passwordPrefix != null)
        password = (samePassword ? passwordPrefix : passwordPrefix + (connectionIndex + 1));

      XMPPConnection con = getConnection(connectionIndex);
     
      if (!con.isConnected())
        con.connect();
      try {
          con.login(usernamePrefix + (connectionIndex + 1), password, "Smack");
      } catch (XMPPException e) {
          createAccount(connectionIndex, usernamePrefix + (connectionIndex + 1), password);
            con.login(usernamePrefix + (connectionIndex + 1), password, "Smack");
      }
    }
View Full Code Here


          if (createdUserIdx.contains(i))
          {
                try {
                    // If not connected, connect so that we can delete the account.
                    if (!getConnection(i).isConnected()) {
                        XMPPConnection con = getConnection(i);
                        con.connect();
                        con.login(getUsername(i), getUsername(i));
                    }
                    else if (!getConnection(i).isAuthenticated()) {
                        getConnection(i).login(getUsername(i), getUsername(i));    
                    }
                    // Delete the created account for the test
View Full Code Here

  /**
   * This is a test to check if a LastActivity request for idle time is
   * answered and correct.
   */
  public void testOnline() {
    XMPPConnection conn0 = getConnection(0);
    XMPPConnection conn1 = getConnection(1);

    // Send a message as the last activity action from connection 1 to
    // connection 0
    conn1.sendPacket(new Message(getBareJID(0)));

    // Wait 1 seconds to have some idle time
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
View Full Code Here

  /**
   * This is a test to check if a denied LastActivity response is handled correctly.
   */
  public void testOnlinePermisionDenied() {
    XMPPConnection conn0 = getConnection(0);
    XMPPConnection conn2 = getConnection(2);

    // Send a message as the last activity action from connection 2 to
    // connection 0
    conn2.sendPacket(new Message(getBareJID(0)));

    // Wait 1 seconds to have some idle time
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
View Full Code Here

  /**
   * This is a test to check if a LastActivity request for last logged out
   * lapsed time is answered and correct
   */
  public void testLastLoggedOut() {
    XMPPConnection conn0 = getConnection(0);

    LastActivity lastActivity = null;
    try {
      lastActivity = LastActivityManager.getLastActivity(conn0, getBareJID(1));
    } catch (XMPPException e) {
View Full Code Here

  /**
   * This is a test to check if a LastActivity request for server uptime
   * is answered and correct
   */
  public void testServerUptime() {
    XMPPConnection conn0 = getConnection(0);

    LastActivity lastActivity = null;
    try {
      lastActivity = LastActivityManager.getLastActivity(conn0, getHost());
    } catch (XMPPException e) {
View Full Code Here

        loginUsername = username;
        loginPassword = password;

        try {
            this.setConnectionState(ConnectionState.CONNECTING, null);
            this.connection = new XMPPConnection(connectionConfiguration);
            this.connection.connect();

            // add connection listener so we get notified if it will be closed
            if (this.smackConnectionListener == null) {
                this.smackConnectionListener = new SafeConnectionListener(log,
View Full Code Here

            monitor = SubMonitor.convert(monitor);

        monitor.beginTask("Registering account...", 3);

        try {
            Connection connection = new XMPPConnection(server);
            monitor.worked(1);

            connection.connect();
            monitor.worked(1);

            String errorMessage = isAccountCreationPossible(connection,
                username);
            if (errorMessage != null)
                throw new XMPPException(errorMessage);

            monitor.worked(1);

            AccountManager manager = connection.getAccountManager();
            manager.createAccount(username, password);
            monitor.worked(1);

            connection.disconnect();
        } catch (XMPPException e) {
            String message = e.getMessage();
            XMPPError error = e.getXMPPError();
            if (error != null) {
                message = error.getMessage();
View Full Code Here

        super(name);
    }

    public void testCompleteJmf() {

        XMPPConnection x0 = getConnection(0);
        XMPPConnection x1 = getConnection(1);

        for (int i = 0; i < 1; i++)
            try {

                ICETransportManager icetm0 = new ICETransportManager(x0, "jivesoftware.com", 3478);
                ICETransportManager icetm1 = new ICETransportManager(x1, "jivesoftware.com", 3478);

                JingleMediaManager jingleMediaManager0 = new JmfMediaManager(icetm0);
                JingleMediaManager jingleMediaManager1 = new JmfMediaManager(icetm1);

                List<JingleMediaManager> jml0 = new ArrayList<JingleMediaManager>();
                List<JingleMediaManager> jml1 = new ArrayList<JingleMediaManager>();

                jml0.add(jingleMediaManager0);
                jml1.add(jingleMediaManager1);

                final JingleManager jm0 = new JingleManager(x0, jml0);
                final JingleManager jm1 = new JingleManager(x1, jml1);

                jm0.addCreationListener(icetm0);
                jm1.addCreationListener(icetm1);

                JingleSessionRequestListener jingleSessionRequestListener = new JingleSessionRequestListener() {
                    public void sessionRequested(final JingleSessionRequest request) {
                        try {
                            JingleSession session = request.accept();
                            session.startIncoming();

                            //                            session.addStateListener(new JingleSessionStateListener() {
                            //                                public void beforeChange(JingleNegotiator.State old, JingleNegotiator.State newOne)
                            //                                        throws JingleNegotiator.JingleException {
                            //                                    if (newOne instanceof IncomingJingleSession.Active) {
                            //                                        throw new JingleNegotiator.JingleException();
                            //                                    }
                            //                                }
                            //
                            //                                public void afterChanged(JingleNegotiator.State old, JingleNegotiator.State newOne) {
                            //
                            //                                }
                            //                            });

                        } catch (XMPPException e) {
                            e.printStackTrace();
                        }

                    }
                };

                jm1.addJingleSessionRequestListener(jingleSessionRequestListener);

                JingleSession js0 = jm0.createOutgoingJingleSession(x1.getUser());

                js0.startOutgoing();

                Thread.sleep(20000);
View Full Code Here

    public void testCompleteMulti() {

        try {

            XMPPConnection x0 = getConnection(0);
            XMPPConnection x1 = getConnection(1);

            ICETransportManager icetm0 = new ICETransportManager(x0, "jivesoftware.com", 3478);
            ICETransportManager icetm1 = new ICETransportManager(x1, "jivesoftware.com", 3478);

            MultiMediaManager jingleMediaManager0 = new MultiMediaManager(icetm0);
            jingleMediaManager0.addMediaManager(new JmfMediaManager(icetm0));
            jingleMediaManager0.addMediaManager(new SpeexMediaManager(icetm0));
            jingleMediaManager0.setPreferredPayloadType(jingleMediaManager0.getPayloads().get(1));
            List<JingleMediaManager> jml0 = new ArrayList<JingleMediaManager>();
            jml0.add(jingleMediaManager0);

            MultiMediaManager jingleMediaManager1 = new MultiMediaManager(icetm1);
            jingleMediaManager1.addMediaManager(new JmfMediaManager(icetm1));
            jingleMediaManager1.addMediaManager(new SpeexMediaManager(icetm1));
            jingleMediaManager1.setPreferredPayloadType(jingleMediaManager1.getPayloads().get(2));
            List<JingleMediaManager> jml1 = new ArrayList<JingleMediaManager>();
            jml1.add(jingleMediaManager1);

            final JingleManager jm0 = new JingleManager(x0, jml0);
            final JingleManager jm1 = new JingleManager(x1, jml1);

            jm0.addCreationListener(icetm0);
            jm1.addCreationListener(icetm1);

            jm1.addJingleSessionRequestListener(new JingleSessionRequestListener() {
                public void sessionRequested(final JingleSessionRequest request) {

                    try {
                        JingleSession session = request.accept();
                        try {
                            Thread.sleep(12000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        session.startIncoming();
                    } catch (XMPPException e) {
                        e.printStackTrace();
                    }

                }
            });

            for (int i = 0; i < 10; i++) {

                JingleSession js0 = jm0.createOutgoingJingleSession(x1.getUser());

                //                js0.addStateListener(new JingleSessionStateListener() {
                //
                //                    public void beforeChange(JingleNegotiator.State old, JingleNegotiator.State newOne)
                //                            throws JingleNegotiator.JingleException {
View Full Code Here

TOP

Related Classes of org.jivesoftware.smack.XMPPConnection

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.