Hi all, i have a smack client on android, and it works well but i have an issue, when i logout and login using different credentials, smack still use my old credentials, even after closing and disconnecting the previous xmpp connection.
private var _xmpptcpConnection: XMPPTCPConnection? = null
override var xmpptcpConnection: XMPPTCPConnection
get() {
if (_xmpptcpConnection == null) {
_xmpptcpConnection =
createXMPPTCPConnection()
}
return _xmpptcpConnection!!
}
set(value) {
_xmpptcpConnection = value
}
private fun createXMPPTCPConnection(): XMPPTCPConnection {
val certificate = loadCertificateFromPEM(AppConstants.pemString.trimIndent())
// Create SSL context with the custom TrustManager
val sslContext = SSLContext.getInstance("TLS")
sslContext.init(
null, arrayOf(createCustomTrustManager(certificate)), java.security.SecureRandom()
)
val configBuilder: XMPPTCPConnectionConfiguration.Builder by lazy {
XMPPTCPConnectionConfiguration.builder()
.setUsernameAndPassword((userid?.also { Timber.tag("UserIdCalled").v(it) })?.substringBeforeLast("@"), "123456")
.setXmppDomain(XMPP_HOST).setPort(AppConstants.PORT).setHost(XMPP_HOST)
.setCompressionEnabled(false).setResource(Resourcepart.from(getResource()))
.enableDefaultDebugger()
.setDebuggerFactory(factory)
.setSecurityMode(ConnectionConfiguration.SecurityMode.required)
.setSendPresence(false)
.setCustomX509TrustManager(createCustomTrustManager(certificate))
}
val connection =XMPPTCPConnection(configBuilder.build())
connection.apply {
addConnectionListener(this@XmppServiceManagerImpl)
replyTimeout = 3000
setUseStreamManagement(true)
setUseStreamManagementResumption(false)
val customAuthText =
"someAuthText"
SASLAuthentication.registerSASLMechanism(CustomSASLMechanism(customAuthText))
SASLAuthentication.unBlacklistSASLMechanism(CustomSASLMechanism.NAME)
}
return connection
}
so this is how i initial my connection above, then below is how i disconnect
override fun disconnect() {
try {
CoroutineScope(Dispatchers.IO).launch {
locked = true
if (xmpptcpConnection.isReady()) {
sendOffinePresence { }
}
xmpptcpConnection.disconnect()
_xmpptcpConnection = null
locked = false
}
}
catch (e:Exception){
e.printStackTrace()
}
finally {
locked=false
}
}
then on new login i called connect again, but it uses previous jid even if i pass a new jid and password, it still uses old login but only uses new resource part,
whats wrong??