本文整理汇总了Java中org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration.builder方法的典型用法代码示例。如果您正苦于以下问题:Java XMPPTCPConnectionConfiguration.builder方法的具体用法?Java XMPPTCPConnectionConfiguration.builder怎么用?Java XMPPTCPConnectionConfiguration.builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration
的用法示例。
在下文中一共展示了XMPPTCPConnectionConfiguration.builder方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConnectionConfigBuilder
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入方法依赖的package包/类
public XMPPTCPConnectionConfiguration.Builder getConnectionConfigBuilder() {
if (!isBasicConfigurationDone()) return null;
if (confBuilderCache == null) {
XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder();
String password = getPassword();
builder.setUsernameAndPassword(getMyJid().getLocalpart(), password);
builder.setXmppDomain(getMyJid().asDomainBareJid());
builder.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
SSLContext sc;
try {
sc = SSLContext.getInstance("TLS");
sc.init(null, new X509TrustManager[] { mMemorizingTrustManager }, new java.security.SecureRandom());
} catch (KeyManagementException | NoSuchAlgorithmException e) {
throw new IllegalStateException(e);
}
builder.setCustomSSLContext(sc);
confBuilderCache = builder;
}
return confBuilderCache;
}
示例2: newConnectionConfiguration
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入方法依赖的package包/类
private XMPPTCPConnectionConfiguration newConnectionConfiguration(final BindingConfiguration configuration){
XMPPTCPConnectionConfiguration.Builder configurationBuilder = XMPPTCPConnectionConfiguration.builder();
configurationBuilder.setHost(configuration.getUrl())
.setPort(configuration.getPort())
.setServiceName(configuration.getServerName())
.setUsernameAndPassword(configuration.getUsername(),configuration.getPassword())
.setResource(configuration.getIdentifier())
.setDebuggerEnabled(configuration.isDebug());
if(allowSelfSigned){
try {
configurationBuilder.setCustomSSLContext(SSLHelper.newAllTrustingSslContext());
} catch (KeyManagementException | NoSuchAlgorithmException e) {
logger.error("Error registering custom ssl context",e);
}
}
return configurationBuilder.build();
}
示例3: connect
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入方法依赖的package包/类
public void connect(String hostname, int port, String username, String password) throws Exception {
purgeTask("reconnect");
this.hostname = hostname;
this.serviceName = hostname;
this.port = port;
this.username = username;
this.password = password;
Builder builder = XMPPTCPConnectionConfiguration.builder();
builder.setUsernameAndPassword(username, password);
builder.setServiceName(serviceName);
builder.setServiceName(hostname);
builder.setPort(port);
builder.setSecurityMode(SecurityMode.disabled);
builder.setDebuggerEnabled(true);
XMPPTCPConnectionConfiguration config = builder.build();
connection = new XMPPTCPConnection(config);
connection.connect().login();
roster = Roster.getInstanceFor(connection);
chatManager = ChatManager.getInstanceFor(connection);
roster.addRosterListener(this);
isConnected = true;
// not worth it - always empty right after connect
// getContactList();
broadcastState();
}
示例4: initPrivateConnection
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入方法依赖的package包/类
private void initPrivateConnection() {
long currentUserId = CurrentUser.getInstance().getCurrentUserId();
String currentUserPassword = CurrentUser.getInstance().getCurrentPassword();
String userName = currentUserId + "-" + ApiConstants.APP_ID;
XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
configBuilder.setUsernameAndPassword(userName, currentUserPassword);
configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
configBuilder.setServiceName(ApiConstants.CHAT_END_POINT);
configBuilder.setHost(ApiConstants.CHAT_END_POINT);
configBuilder.setDebuggerEnabled(true);
privateChatConnection = new XMPPTCPConnection(configBuilder.build());
privateChatConnection.addConnectionListener(this);
ReconnectionManager manager = ReconnectionManager.getInstanceFor(privateChatConnection);
manager.enableAutomaticReconnection();
manager.setReconnectionPolicy(ReconnectionManager.ReconnectionPolicy.FIXED_DELAY);
manager.setFixedDelay(15);
ProviderManager.addExtensionProvider(Displayed.ELEMENT, Displayed.NAMESPACE, new Displayed.Provider());
DisplayedManager.getInstanceFor(privateChatConnection).addDisplayedListener(
(fromJid, toJid, receiptId, receipt) -> {
messageService.get().processDisplayed(fromJid, toJid, receiptId, receipt);
});
ProviderManager.addExtensionProvider(Received.ELEMENT, Received.NAMESPACE, new Received.Provider());
ReceivedManager.getInstanceFor(privateChatConnection).addReceivedListener(
(fromJid, toJid, receiptId, receipt) -> {
messageService.get().processReceived(fromJid, toJid, receiptId, receipt);
});
}
示例5: buildConfiguration
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入方法依赖的package包/类
private XMPPTCPConnectionConfiguration buildConfiguration() throws XmppStringprepException {
XMPPTCPConnectionConfiguration.Builder builder =
XMPPTCPConnectionConfiguration.builder();
builder.setHost(HOST1);
builder.setPort(PORT);
builder.setCompressionEnabled(false);
builder.setDebuggerEnabled(true);
builder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
builder.setSendPresence(true);
if (Build.VERSION.SDK_INT >= 14) {
builder.setKeystoreType("AndroidCAStore");
// config.setTruststorePassword(null);
builder.setKeystorePath(null);
} else {
builder.setKeystoreType("BKS");
String str = System.getProperty("javax.net.ssl.trustStore");
if (str == null) {
str = System.getProperty("java.home") + File.separator + "etc" + File.separator + "security"
+ File.separator + "cacerts.bks";
}
builder.setKeystorePath(str);
}
DomainBareJid serviceName = JidCreate.domainBareFrom(HOST);
builder.setServiceName(serviceName);
return builder.build();
}
示例6: getConnection
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入方法依赖的package包/类
public static AbstractXMPPConnection getConnection() {
if ( XMPPConnectionManager.isConfigured == false ) {
Log.w(LOGTAG, "Instating unconfigured connection" );
return null;
}
if ( XMPPConnectionManager.isConnected == false ) {
// Send the configuration
// TODO: Yes I know, this is restrictive, DNS must be working
XMPPTCPConnectionConfiguration.Builder configBuilder =
XMPPTCPConnectionConfiguration.builder();
configBuilder.setUsernameAndPassword(
XMPPConnectionManager.xmppUserName,
XMPPConnectionManager.xmppPassword);
configBuilder.setServiceName( XMPPConnectionManager.xmppUserDomain );
configBuilder.setResource( "FlowsManager" );
XMPPConnectionManager.connection = new XMPPTCPConnection(configBuilder.build());
try {
// Create a connection to the XMPP server.
XMPPConnectionManager.connection.connect();
// Log into the server
XMPPConnectionManager.connection.login();
} catch (Exception ex) {
Log.w(LOGTAG, "XMPP Connection error " + ex);
return null ;
}
XMPPConnectionManager.isConnected = true ;
}
return XMPPConnectionManager.connection ;
}
示例7: setup
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入方法依赖的package包/类
public void setup() {
this.configBuilder = XMPPTCPConnectionConfiguration.builder();
this.configBuilder.setUsernameAndPassword(XMPPConnectionHandler.username, XMPPConnectionHandler.password);
this.configBuilder.setResource(XMPPConnectionHandler.resource);
this.configBuilder.setServiceName(XMPPConnectionHandler.service);
this.configBuilder.setHost(XMPPConnectionHandler.host);
this.configBuilder.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
this.connection = new XMPPTCPConnection(this.configBuilder.build());
}
示例8: buildConfiguration
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入方法依赖的package包/类
private static XMPPTCPConnectionConfiguration buildConfiguration(String resource,
EndpointServer server, boolean secure, PrivateKey privateKey, X509Certificate bridgeCert,
boolean acceptAnyCertificate, KeyStore trustStore, String legacyAuthToken) throws XmppStringprepException {
XMPPTCPConnectionConfiguration.Builder builder =
XMPPTCPConnectionConfiguration.builder();
String host = server.getHost();
InetAddress inetAddress = null;
if (host != null) {
try {
inetAddress = InetAddress.getByName(host);
}
catch (UnknownHostException e) {
Log.w(TAG, "unable to resolve host " + host + ", will try again during connect", e);
}
}
builder
// connection parameters
.setHostAddress(inetAddress)
// try a last time through Smack
.setHost(inetAddress != null ? null : host)
.setPort(secure ? server.getSecurePort() : server.getPort())
.setXmppDomain(server.getNetwork())
.setResource(resource)
// the dummy value is not actually used
.setUsernameAndPassword(null, legacyAuthToken != null ? legacyAuthToken : "dummy")
// for EXTERNAL
.allowEmptyOrNullUsernames()
// enable compression
.setCompressionEnabled(true)
// enable encryption
.setSecurityMode(secure ? SecurityMode.disabled : SecurityMode.required)
// we will send a custom presence
.setSendPresence(false)
// disable session initiation
.setLegacySessionDisabled(true)
// enable debugging
.setDebuggerEnabled(Log.isDebug());
// setup SSL
setupSSL(builder, secure, privateKey, bridgeCert, acceptAnyCertificate, trustStore);
return builder.build();
}
示例9: connect
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; //导入方法依赖的package包/类
public void connect() throws IOException, XMPPException, SmackException {
Log.i(TAG, "connect()");
XMPPTCPConnectionConfiguration.XMPPTCPConnectionConfigurationBuilder builder = XMPPTCPConnectionConfiguration.builder();
builder.setServiceName(mServiceName);
builder.setResource("SmackAndroidTestClient");
builder.setUsernameAndPassword(mUsername, mPassword);
builder.setRosterLoadedAtLogin(true);
mConnection = new XMPPTCPConnection(builder.build());
//Set ConnectionListener here to catch initial connect();
mConnection.addConnectionListener(this);
mConnection.connect();
mConnection.login();
PingManager.setDefaultPingInterval(600); //Ping every 10 minutes
PingManager pingManager = PingManager.getInstanceFor(mConnection);
pingManager.registerPingFailedListener(this);
setupSendMessageReceiver();
ChatManager.getInstanceFor(mConnection).addChatListener(this);
mConnection.getRoster().addRosterListener(this);
}