本文整理汇总了Java中org.jivesoftware.smack.ConnectionConfiguration.setCompressionEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectionConfiguration.setCompressionEnabled方法的具体用法?Java ConnectionConfiguration.setCompressionEnabled怎么用?Java ConnectionConfiguration.setCompressionEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.ConnectionConfiguration
的用法示例。
在下文中一共展示了ConnectionConfiguration.setCompressionEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connect
import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
public static XMPPConnection connect(String host) throws XMPPException
{
ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration(host, 5222, "excalibur.org");
connectionConfiguration.setCompressionEnabled(false);
connectionConfiguration.setSelfSignedCertificateEnabled(true);
connectionConfiguration.setExpiredCertificatesCheckEnabled(false);
connectionConfiguration.setDebuggerEnabled(false);
connectionConfiguration.setSASLAuthenticationEnabled(true);
connectionConfiguration.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
//XMPPConnection.DEBUG_ENABLED = false;
XMPPConnection connection = new XMPPConnection(connectionConfiguration);
connection.connect();
return connection;
}
示例2: build
import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
public ConnectionConfiguration build()
{
Preconditions.checkArgument(!Strings.isNullOrEmpty(this.host_) && !Strings.isNullOrEmpty(this.serviceName_));
ConnectionConfiguration configuration = new ConnectionConfiguration(host_, port_, serviceName_);
configuration.setCompressionEnabled(this.compressionEnabled_);
configuration.setSelfSignedCertificateEnabled(this.selfSignedCertificateEnabled_);
configuration.setExpiredCertificatesCheckEnabled(this.expiredCertificatesCheckEnabled_);
configuration.setSASLAuthenticationEnabled(this.saaslAuthenticationEnabled_);
configuration.setSecurityMode(this.securityMode_);
configuration.setRosterLoadedAtLogin(this.loadRosterAtLogin_);
configuration.setSendPresence(this.sendPresence_);
return configuration;
}
示例3: LolChat
import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
/**
* 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();
}
示例4: makeXMPPConnection
import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
private Connection makeXMPPConnection(String username, String password){
// Create the configuration for this new connection
ConnectionConfiguration config = new ConnectionConfiguration("libraryh3lp.com", 5222);
config.setCompressionEnabled(true);
config.setSASLAuthenticationEnabled(true);
// Create the connection and log in
Connection con = new XMPPConnection(config);
try {
con.connect();
con.login(username, password);
} catch (XMPPException e) {
e.printStackTrace();
con = null;
}
return con;
}
示例5: initConnect
import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
/**
* 通过主机名和端口号去对服务器进行连接和一些初始化
*/
private void initConnect() {
if (!isConnected()) {
String connectionHost = mNotificationService.getHost();
int connectionPort = Integer.parseInt(mNotificationService
.getPort());
ConnectionConfiguration connConfig = new ConnectionConfiguration(
connectionHost, connectionPort);
connConfig.setSecurityMode(SecurityMode.required);
connConfig.setSASLAuthenticationEnabled(false);
connConfig.setCompressionEnabled(false);
mConnection = new XMPPConnection(connConfig);
try {
mConnection.connect();
ProviderManager.getInstance().addIQProvider(ELEMENT_NAME,
NAME_SPACE, new NotificationIQProvider());
} catch (XMPPException e) {
startReconnection();
}
}
}
示例6: init
import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
/**
* <b>function:</b> ��ʼSmack��openfire���������ӵĻ�������
*
* @author hoojo
* @createDate 2012-6-25 ����04:06:42
*/
public static void init() {
try {
// connection = new XMPPConnection(server);
// connection.connect();
/**
* 5222��openfire������Ĭ�ϵ�ͨ�Ŷ˿ڣ�����Ե�¼http://192.168.8.32:9090/
* ������Ա����̨�鿴�ͻ��˵��������˿�
*/
config = new ConnectionConfiguration(server, 5222);
/** �Ƿ�����ѹ�� */
config.setCompressionEnabled(true);
/** �Ƿ����ð�ȫ��֤ */
config.setSASLAuthenticationEnabled(false);
/** �Ƿ����õ��� */
config.setDebuggerEnabled(false);
// config.setReconnectionAllowed(true);
// config.setRosterLoadedAtLogin(true);
/** ����connection���� */
connection = new XMPPConnection(config);
/** �������� */
connection.connect();
} catch (XMPPException e) {
e.printStackTrace();
}
// fail(connection);
// fail(connection.getConnectionID());
}
示例7: run
import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
public void run() {
Log.i(LOGTAG, "ConnectTask.run()...");
boolean connected = false;
if (!xmppManager.isConnected()) {
// Create the configuration for this new connection
ConnectionConfiguration connConfig = new ConnectionConfiguration(
xmppHost, xmppPort);
// connConfig.setSecurityMode(SecurityMode.disabled);
connConfig.setSecurityMode(SecurityMode.required);
connConfig.setSASLAuthenticationEnabled(false);
connConfig.setCompressionEnabled(false);
XMPPConnection connection = new XMPPConnection(connConfig);
xmppManager.setConnection(connection);
try {
// Connect to the server
connection.connect();
Log.i(LOGTAG, "XMPP connected successfully");
// packet provider
ProviderManager.getInstance().addIQProvider("notification",
"androidpn:iq:notification",
new NotificationIQProvider());
connected = true;
} catch (XMPPException e) {
Log.e(LOGTAG, "XMPP connection failed", e);
}
if (connected) {
xmppManager.runTask();
}
} else {
Log.i(LOGTAG, "XMPP connected already");
xmppManager.runTask();
}
}
示例8: createConnection
import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
/**
* 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);
}
示例9: run
import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
public void run() {
Log.i(LOGTAG, "ConnectTask.run()...");
if (!xmppManager.isConnected()) {
// Create the configuration for this new connection
ConnectionConfiguration connConfig = new ConnectionConfiguration(
xmppHost, xmppPort);
// connConfig.setSecurityMode(SecurityMode.disabled);
connConfig.setSecurityMode(SecurityMode.required);
connConfig.setSASLAuthenticationEnabled(false);
connConfig.setCompressionEnabled(false);
XMPPConnection connection = new XMPPConnection(connConfig);
xmppManager.setConnection(connection);
try {
// Connect to the server
connection.connect();
Log.i(LOGTAG, "XMPP connected successfully");
// packet provider
ProviderManager.getInstance().addIQProvider("notification",
"androidpn:iq:notification",
new NotificationIQProvider());
} catch (XMPPException e) {
Log.e(LOGTAG, "XMPP connection failed", e);
}
xmppManager.runTask();
} else {
Log.i(LOGTAG, "XMPP connected already");
xmppManager.runTask();
}
}
示例10: run
import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
public void run() {
Log.i(LOGTAG, "ConnectTask.run()...");
if (!xmppManager.isConnected()) {
// Create the configuration for this new connection
ConnectionConfiguration connConfig = new ConnectionConfiguration(
xmppHost, xmppPort);
// connConfig.setSecurityMode(SecurityMode.disabled);
connConfig.setSecurityMode(SecurityMode.required);
connConfig.setSASLAuthenticationEnabled(false);
connConfig.setCompressionEnabled(false);
XMPPConnection connection = new XMPPConnection(connConfig);
xmppManager.setConnection(connection);
try {
// Connect to the server
connection.connect();
Log.i(LOGTAG, "XMPP connected successfully");
// packet provider
ProviderManager.getInstance().addIQProvider("notification",
"androidpn:iq:notification",
new NotificationIQProvider());
xmppManager.runTask();
} catch (XMPPException e) {
Log.e(LOGTAG, "XMPP connection failed", e);
xmppManager.dropTask(2);
xmppManager.startReconnectionThread();
xmppManager.runTask();
}
} else {
Log.i(LOGTAG, "XMPP connected already");
xmppManager.runTask();
}
}
示例11: run
import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
public void run() {
if (!xmppManager.isConnected()) {
// Create the configuration for this new connection
ConnectionConfiguration connConfig = new ConnectionConfiguration(xmppHost, xmppPort);
// connConfig.setSecurityMode(SecurityMode.disabled);
// connConfig.setSecurityMode(SecurityMode.required);
connConfig.setSASLAuthenticationEnabled(false);
connConfig.setCompressionEnabled(false);
connConfig.setSecurityMode(SecurityMode.disabled);
XMPPConnection connection = new XMPPConnection(connConfig);
xmppManager.setConnection(connection);
try {
// Connect to the server
connection.connect();
// packet provider
ProviderManager.getInstance().addIQProvider("notification", "androidpn:iq:notification", new NotificationIQProvider());
reconnection.waiting = 0;
reconnection.needWork.set(false);
} catch (XMPPException e) {
e.printStackTrace();
}
xmppManager.runTask();
} else {
xmppManager.runTask();
}
}
示例12: LolChat
import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
/**
* 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,
String riotApiKey) {
this.friendRequestPolicy = friendRequestPolicy;
if (riotApiKey != null && server.api != null) {
this.riotApi = new JRiot(riotApiKey, server.name().toLowerCase());
}
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);
try {
connection.connect();
} catch (Exception e) {
System.err.println("Failed to connect to " + server.host);
return;
}
addListeners();
new Thread(new Runnable() {
@Override
public void run() {
while (!stop) {
try {
Thread.sleep(500);//NOT SURE ABOUT THIS, TODO:REVIST
} catch (final InterruptedException ignored) {
}
}
}
}).start();
}
示例13: run
import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
public void run() {
Log.i(LOGTAG, "ConnectTask.run()...");
if (!XmppManager.isConnected(xmppManager)) {
// Create the configuration for this new connection
ConnectionConfiguration connConfig = new ConnectionConfiguration(
xmppHost, xmppPort);
connConfig.setSecurityMode(SecurityMode.disabled);
connConfig.setSASLAuthenticationEnabled(false);
connConfig.setCompressionEnabled(false);
XMPPConnection connection = new XMPPConnection(connConfig);
XmppManager.setXMPPConnection(xmppManager, connection);
try {
// Connect to the server
connection.connect();
Log.i(LOGTAG, "XMPP connected successfully");
// packet provider
ProviderManager.getInstance().addIQProvider("notification",
"androidpn:iq:notification",
new NotificationProvider());
} catch (XMPPException e) {
Log.e(LOGTAG, "XMPP connection failed", e);
}
XmppManager.runTask(xmppManager);
} else {
Log.i(LOGTAG, "XMPP connected already");
XmppManager.runTask(xmppManager);
}
}
示例14: run
import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
public void run() {
Log.i(LOGTAG, "ConnectTask.run()...");
if (!xmppManager.isConnected()) {
// Create the configuration for this new connection
ConnectionConfiguration connConfig = new ConnectionConfiguration(
xmppHost, xmppPort);
connConfig.setSecurityMode(SecurityMode.disabled);
connConfig.setSASLAuthenticationEnabled(false);
connConfig.setCompressionEnabled(false);
XMPPConnection connection = new XMPPConnection(connConfig);
xmppManager.setConnection(connection);
try {
// Connect to the server
connection.connect();
Log.i(LOGTAG, "XMPP connected successfully");
// packet provider
ProviderManager.getInstance().addIQProvider("notification",
"androidpn:iq:notification",
new NotificationIQProvider());
} catch (XMPPException e) {
Log.e(LOGTAG, "XMPP connection failed", e);
}
xmppManager.runTask();
} else {
Log.i(LOGTAG, "XMPP connected already");
xmppManager.runTask();
}
}
示例15: run
import org.jivesoftware.smack.ConnectionConfiguration; //导入方法依赖的package包/类
public void run() {
Log.i(LOGTAG, "ConnectTask.run()...");
if (!XmppManager.isConnected(xmppManager)) {
// Create the configuration for this new connection
ConnectionConfiguration connConfig = new ConnectionConfiguration(
xmppHost, xmppPort);
connConfig.setSecurityMode(SecurityMode.disabled);
connConfig.setSASLAuthenticationEnabled(false);
connConfig.setCompressionEnabled(false);
XMPPConnection connection = new XMPPConnection(connConfig);
XmppManager.setXMPPConnection(xmppManager, connection);
try {
// Connect to the server
connection.connect();
Log.i(LOGTAG, "XMPP connected successfully");
// packet provider
ProviderManager.getInstance().addIQProvider("notification",
"androidpn:iq:notification",
new NotificationIQProvider());
} catch (XMPPException e) {
Log.e(LOGTAG, "XMPP connection failed", e);
}
XmppManager.runTask(xmppManager);
} else {
Log.i(LOGTAG, "XMPP connected already");
XmppManager.runTask(xmppManager);
}
}