Package org.jivesoftware.smack

Examples of org.jivesoftware.smack.XMPPConnection


    FileConfiguration cnf = CommandsEX.getConf();
    if (cnf.getBoolean("xmppEnabled")) {
      LogHelper.logInfo("[CommandsEX] " + _("xmppConnecting", ""));
      cmdPrefix = cnf.getString("xmppCommandPrefix", "#");
      participantNicks = new HashMap<String, String>();
      xmppConnection = new XMPPConnection(cnf.getString("xmppHost", "localhost"));
      try {
        xmppConnection.connect();
        if (cnf.getString("xmppUser", "").equals("")) {
          LogHelper.logInfo(_("xmppAnonymousLogin", ""));
          xmppConnection.loginAnonymously();
View Full Code Here


   
    Marshaller marshaller;
  DatatypeFactory xmlDataTypeFac;
   
    protected XMPPConnection connect(String resource) throws XMPPException {
      XMPPConnection c = new XMPPConnection(connConfig);
     
        c.connect();
        c.login(username, passwd, resource);       
        Presence presence = new Presence(Presence.Type.available);
        c.sendPacket(presence);
       
        return c;
    }
View Full Code Here

   
    Marshaller marshaller;
  DatatypeFactory xmlDataTypeFac;
   
    protected XMPPConnection connect(String resource) throws XMPPException {
      XMPPConnection c = new XMPPConnection(connConfig);
     
        c.connect();
        c.login(username, passwd, resource);       
//        Presence presence = new Presence(Presence.Type.available);
//        c.sendPacket(presence);
       
        return c;
    }
View Full Code Here

            } else {
                config = new ConnectionConfiguration(uri.getHost(), port);

            }

            xmppConnection = new XMPPConnection(config);
            xmppConnection.connect();
            SASLAuthentication.supportSASLMechanism("PLAIN", 0);
            String[] credentials = authToken.split(":");

            xmppConnection.login(credentials[0], credentials[1], getID());
View Full Code Here

    }

    // Implementation methods
    // -------------------------------------------------------------------------
    protected XMPPConnection createConnection() throws XMPPException {
        XMPPConnection connection;
        if (port > 0) {
            connection = new XMPPConnection(host, port);
        } else {
            connection = new XMPPConnection(host);
        }
        if (login && !connection.isAuthenticated()) {
            if (user != null) {
                LOG.info("Logging in to XMPP as user: " + user + " on connection: " + connection);
                if (password == null) {
                    LOG.warn("No password configured for user: " + user);
                }

                if (createAccount) {
                    AccountManager accountManager = new AccountManager(connection);
                    accountManager.createAccount(user, password);
                }
                if (resource != null) {
                    connection.login(user, password, resource);
                } else {
                    connection.login(user, password);
                }
            } else {
                LOG.info("Logging in anonymously to XMPP on connection: " + connection);
                connection.loginAnonymously();
            }

            // now lets send a presence
            connection.sendPacket(new Presence(Presence.Type.AVAILABLE));
        }
        return connection;
    }
View Full Code Here

    }

    // Implementation methods
    // -------------------------------------------------------------------------
    protected XMPPConnection createConnection() throws XMPPException {
        XMPPConnection connection;
        if (port > 0) {
            connection = new XMPPConnection(new ConnectionConfiguration(host, port));
        } else {
            connection = new XMPPConnection(host);
        }

        connection.connect();

        if (login && !connection.isAuthenticated()) {
            if (user != null) {
                LOG.info("Logging in to XMPP as user: " + user + " on connection: " + connection);
                if (password == null) {
                    LOG.warn("No password configured for user: " + user);
                }

                if (createAccount) {
                    AccountManager accountManager = new AccountManager(connection);
                    accountManager.createAccount(user, password);
                }
                if (resource != null) {
                    connection.login(user, password, resource);
                } else {
                    connection.login(user, password);
                }
            } else {
                LOG.info("Logging in anonymously to XMPP on connection: " + connection);
                connection.loginAnonymously();
            }

            // presence is not needed to be sent after login
        }
        return connection;
View Full Code Here

        if (room.indexOf('@', 0) != -1) {
            return room;
        }

        XMPPConnection conn = getConnection();
        Iterator<String> iterator = MultiUserChat.getServiceNames(conn).iterator();
        if (!iterator.hasNext()) {
            throw new CamelException("Can not find Multi User Chat service");
        }
        String chatServer = iterator.next();
View Full Code Here

        connectionConfiguration.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
        connectionConfiguration.setSASLAuthenticationEnabled(true);
        connectionConfiguration.setDebuggerEnabled(false);
       
        XMPPConnection.DEBUG_ENABLED = true;
        XMPPConnection client = new XMPPConnection(connectionConfiguration);
       
        client.connect();
       
        client.login(username, password);
        return client;
    }
View Full Code Here

        pubsubMgr = new PubSubManager(connection);
        return true;
    }

    private XMPPConnection connect(String username, String password, String host) throws XMPPException {
        XMPPConnection connection = new XMPPConnection(host);
        connection.connect();
        connection.login(username, password);
        return connection;
    }
View Full Code Here

    }

    // Implementation methods
    // -------------------------------------------------------------------------
    protected XMPPConnection createConnection() throws XMPPException {
        XMPPConnection connection;
        if (port > 0) {           
            if (getServiceName() == null) {
                connection = new XMPPConnection(new ConnectionConfiguration(host, port));
            } else {
                connection = new XMPPConnection(new ConnectionConfiguration(host, port, getServiceName()));
            }
        } else {
            connection = new XMPPConnection(host);
        }

        connection.connect();

        if (login && !connection.isAuthenticated()) {
            if (user != null) {
                LOG.info("Logging in to XMPP as user: " + user + " on connection: " + connection);
                if (password == null) {
                    LOG.warn("No password configured for user: " + user);
                }

                if (createAccount) {
                    AccountManager accountManager = new AccountManager(connection);
                    accountManager.createAccount(user, password);
                }
                if (resource != null) {
                    connection.login(user, password, resource);
                } else {
                    connection.login(user, password);
                }
            } else {
                LOG.info("Logging in anonymously to XMPP on connection: " + connection);
                connection.loginAnonymously();
            }

            // presence is not needed to be sent after login
        }
        return connection;
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.