Package org.jivesoftware.smack

Examples of org.jivesoftware.smack.ConnectionConfiguration


     *
     * @return a new XMPP connection.
     */
    protected XMPPConnection createConnection() {
        // Create the configuration for this new connection
        ConnectionConfiguration config = new ConnectionConfiguration(host, port);
        config.setCompressionEnabled(compressionEnabled);
        config.setSendPresence(sendInitialPresence());
        if (getSocketFactory() == null) {
            config.setSocketFactory(getSocketFactory());
        }
        return new XMPPConnection(config);
    }
View Full Code Here


    }

    public void testAnonymousParticipant() {
        try {
            // Anonymous user joins the new room
            ConnectionConfiguration connectionConfiguration =
                    new ConnectionConfiguration(getHost(), getPort(), getServiceName());
            XMPPConnection anonConnection = new XMPPConnection(connectionConfiguration);
            anonConnection.connect();
            anonConnection.loginAnonymously();
            MultiUserChat muc2 = new MultiUserChat(anonConnection, room);
            muc2.join("testbot2");
View Full Code Here

    public void testManyResources() throws Exception {
            // Create 5 more connections for user2
            XMPPConnection[] conns = new XMPPConnection[5];
            for (int i = 0; i < conns.length; i++) {
                ConnectionConfiguration connectionConfiguration =
                        new ConnectionConfiguration(getHost(), getPort(), getServiceName());
                connectionConfiguration.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
                conns[i] = new XMPPConnection(connectionConfiguration);
                conns[i].connect();
                conns[i].login(getUsername(1), getPassword(1), "resource-" + i);
                Thread.sleep(20);
            }
View Full Code Here

            return connection;
        }

        if (port > 0) {
            if (getServiceName() == null) {
                connection = new XMPPConnection(new ConnectionConfiguration(host, port));
            } else {
                connection = new XMPPConnection(new ConnectionConfiguration(host, port, serviceName));
            }
        } else {
            connection = new XMPPConnection(host);
        }
View Full Code Here

      @Named("port") final Integer port) {
    super();

    this.chatHandler = Sets.newHashSet();

    this.connection = new XMPPConnection(new ConnectionConfiguration(host,
        port));
    this.connection.getChatManager().addChatListener(
        new ChatManagerListener() {

          @Override
View Full Code Here

        }

        if (connection == null) {
            if (port > 0) {
                if (getServiceName() == null) {
                    connection = new XMPPConnection(new ConnectionConfiguration(host, port));
                } else {
                    connection = new XMPPConnection(new ConnectionConfiguration(host, port, serviceName));
                }
            } else {
                connection = new XMPPConnection(host);
            }
        }
View Full Code Here

    }
  }

  private static void establishConnection() {
    if (servername != null) {
      ConnectionConfiguration config;
      // Create a connection to the jabber server on the given port
      if (proxy != null) {
        config = new ConnectionConfiguration(servername, port, proxy);
      } else {
        config = new ConnectionConfiguration(servername, port);
      }

      if (connection != null && connection.isConnected()) {
        try {
          connection.disconnect();
View Full Code Here

        || serverResource.equals(XMPPID.PATH_DELIMITER)) {
      serverResource = getClientIdentifier();
      jabberURI.setResourceName(serverResource);
    }
    try {
      ConnectionConfiguration config;
      if (hostnameOverride != null) {
        config = new ConnectionConfiguration(hostnameOverride,
            XMPP_DEFAULT_PORT, serviceName);
      } else if (serverPort == -1) {
        config = new ConnectionConfiguration(serviceName);
      } else {
        config = new ConnectionConfiguration(serviceName, serverPort);
      }
      config.setSendPresence(true);
      // Handler is only used if server requires certificate for
      // authentication; handler should provide keystore password:
      if (callbackHandler instanceof javax.security.auth.callback.CallbackHandler) {
        config.setCallbackHandler((javax.security.auth.callback.CallbackHandler) callbackHandler);
      }
      connection = new XMPPConnection(config);
      connection.connect();

      SASLAuthentication.supportSASLMechanism("PLAIN", 0);
View Full Code Here

TOP

Related Classes of org.jivesoftware.smack.ConnectionConfiguration

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.