Switched to SDK 5.0 and use new Account object instead of deprecated ProxyConfig
This commit is contained in:
@@ -45,6 +45,6 @@ dependencies {
|
||||
implementation 'androidx.core:core-ktx:1.3.2'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'com.google.android.material:material:1.2.1'
|
||||
// Latest version is 4.5.x, using + to get the latest available
|
||||
implementation 'org.linphone:linphone-sdk-android:4.5+'
|
||||
// Latest version is 5.0.x, using + to get the latest available
|
||||
implementation 'org.linphone:linphone-sdk-android:5.0+'
|
||||
}
|
||||
@@ -34,17 +34,12 @@ class BasicChatActivity: AppCompatActivity() {
|
||||
private var chatRoom: ChatRoom? = null
|
||||
|
||||
private val coreListener = object: CoreListenerStub() {
|
||||
override fun onRegistrationStateChanged(
|
||||
core: Core,
|
||||
proxyConfig: ProxyConfig,
|
||||
state: RegistrationState?,
|
||||
message: String
|
||||
) {
|
||||
override fun onAccountRegistrationStateChanged(core: Core, account: Account, state: RegistrationState?, message: String) {
|
||||
findViewById<TextView>(R.id.registration_status).text = message
|
||||
|
||||
if (state == RegistrationState.Failed) {
|
||||
core.clearAllAuthInfo()
|
||||
core.clearProxyConfig()
|
||||
core.clearAccounts()
|
||||
findViewById<Button>(R.id.connect).isEnabled = true
|
||||
} else if (state == RegistrationState.Ok) {
|
||||
findViewById<LinearLayout>(R.id.register_layout).visibility = View.GONE
|
||||
@@ -139,19 +134,20 @@ class BasicChatActivity: AppCompatActivity() {
|
||||
}
|
||||
val authInfo = Factory.instance().createAuthInfo(username, null, password, null, null, domain, null)
|
||||
|
||||
val proxyConfig = core.createProxyConfig()
|
||||
val params = core.createAccountParams()
|
||||
val identity = Factory.instance().createAddress("sip:$username@$domain")
|
||||
proxyConfig.identityAddress = identity
|
||||
params.identityAddress = identity
|
||||
|
||||
val address = Factory.instance().createAddress("sip:$domain")
|
||||
address?.transport = transportType
|
||||
proxyConfig.serverAddr = address?.asStringUriOnly()
|
||||
proxyConfig.enableRegister(true)
|
||||
params.serverAddress = address
|
||||
params.registerEnabled = true
|
||||
val account = core.createAccount(params)
|
||||
|
||||
core.addAuthInfo(authInfo)
|
||||
core.addProxyConfig(proxyConfig)
|
||||
core.addAccount(account)
|
||||
|
||||
core.defaultProxyConfig = proxyConfig
|
||||
core.defaultAccount = account
|
||||
core.addListener(coreListener)
|
||||
core.start()
|
||||
}
|
||||
@@ -173,7 +169,7 @@ class BasicChatActivity: AppCompatActivity() {
|
||||
|
||||
if (remoteAddress != null) {
|
||||
// And finally we will need our local SIP address
|
||||
val localAddress = core.defaultProxyConfig?.identityAddress
|
||||
val localAddress = core.defaultAccount?.params?.identityAddress
|
||||
val room = core.createChatRoom(params, localAddress, arrayOf(remoteAddress))
|
||||
if (room != null) {
|
||||
chatRoom = room
|
||||
|
||||
Reference in New Issue
Block a user