Java Code Examples for org.jivesoftware.smack.ConnectionConfiguration#setSocketFactory()

The following examples show how to use org.jivesoftware.smack.ConnectionConfiguration#setSocketFactory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LolChat.java    From League-of-Legends-XMPP-Chat-Library with MIT License 6 votes vote down vote up
/**
 * Represents a single connection to a League of Legends chatserver.
 * 
 * @param server
 *            The chatserver of the region you want to connect to
 * @param friendRequestPolicy
 *            Determines how new Friend requests are treated.
 * @param riotApiKey
 *            Your apiKey used to convert summonerId's to name. You can get
 *            your key here <a
 *            href="https://developer.riotgames.com/">developer
 *            .riotgames.com</a>
 * 
 * @see LolChat#setFriendRequestPolicy(FriendRequestPolicy)
 * @see LolChat#setFriendRequestListener(FriendRequestListener)
 */
public LolChat(ChatServer server, FriendRequestPolicy friendRequestPolicy,
		RiotApiKey riotApiKey) {
	this.friendRequestPolicy = friendRequestPolicy;
	this.server = server;
	if (riotApiKey != null && server.api != null) {
		this.riotApi = RiotApi.build(riotApiKey, server);
	}
	Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
	final ConnectionConfiguration config = new ConnectionConfiguration(
			server.host, 5223, "pvp.net");
	config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
	config.setSocketFactory(SSLSocketFactory.getDefault());
	config.setCompressionEnabled(true);
	connection = new XMPPTCPConnection(config);

	addListeners();
}
 
Example 2
Source File: SmackGcmSenderChannel.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
/**
 * Connects to GCM Cloud Connection Server using the supplied credentials.
 *
 * @param senderId
 *            Your GCM project number
 * @param apiKey
 *            API Key of your project
 */
protected void connect(long senderId, String apiKey, int keepAliveInterval) throws XMPPException, IOException, SmackException {

    // Configure connection
    ConnectionConfiguration config = new ConnectionConfiguration(GcmServiceConstants.GCM_SERVER, GcmServiceConstants.GCM_PORT);
    config.setSecurityMode(SecurityMode.enabled);
    config.setReconnectionAllowed(true);
    config.setRosterLoadedAtLogin(false);
    config.setSendPresence(false);
    config.setSocketFactory(SSLSocketFactory.getDefault());

    // Create connection object and initiate connection
    connection = new XMPPTCPConnection(config);
    pingManager = PingManager.getInstanceFor(connection);
    pingManager.setPingInterval(keepAliveInterval);
    pingManager.registerPingFailedListener(this);
    connection.connect();

    // Register listener to log connection state events
    connection.addConnectionListener(new SmackLoggingConnectionListener());

    // Handle incoming messages (delivery receipts and Google control messages)
    connection.addPacketListener(upstreamListener, new PacketTypeFilter(Message.class));

    // Log in...
    connection.login(senderId + "@" + GcmServiceConstants.GCM_SERVER, apiKey);
}
 
Example 3
Source File: SmackTestCase.java    From Smack with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new XMPPTCPConnection using the connection preferences. This is useful when
 * not using a connection from the connection pool in a test case.
 *
 * @return a new XMPP connection.
 */
protected XMPPTCPConnection 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 XMPPTCPConnection(config);
}
 
Example 4
Source File: XmppClient.java    From riotapi with Apache License 2.0 4 votes vote down vote up
private static ConnectionConfiguration buildConnectionConfiguration(Shard shard) {
	ConnectionConfiguration connConf = new ConnectionConfiguration(shard.chatUrl, Shard.JABBER_PORT, "pvp.net");
	connConf.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
	connConf.setSocketFactory(SSLSocketFactory.getDefault());
	return connConf;
}