Environment:
Ejabberd Version : 16.04
Smack-android-4.1.0
我正在开发一个 Android 聊天应用程序。目前,可以使用相同的用户凭据从多个设备登录。
当前场景如下:
1. User logs in into the app in device A
2. Using the same username and password, the user logs successfully into the app in device B
3. Now device A says, it is disconnected, but continue the chat in device B
但是,根据给定的要求,它的行为应该是这样的:
1. User logs in into the app in device A
2. Using the same username and password, when the user tries to log in from device B, it should not allow it.
(Since he is already logged in from device A)
很高兴听到您对此的解决方案/想法。提前致谢。
最佳答案
所以我设法使用选项resource_conflict解决了问题
The option resource_conflict defines the action when a client attempts to login to an account with a resource that is already connected. The option syntax is:
resource_conflict: setresource|closenew|closeold: The possible values match exactly the three possibilities described in XMPP Core: section 7.7.2.2. The default value is closeold. If the client uses old Jabber Non-SASL authentication (XEP-0078), then this option is not respected, and the action performed is closeold.
因此,打开 ejabberd.yml
并将以下行添加到该文件中。
resource_conflict: closenew
然后重新启动ejabberd服务器。
现在它将禁止新连接客户端的资源绑定(bind)尝试并维持当前连接客户端的 session 。
引用文献:
关于android - 在 Ejabberd/XMPP 中禁止用户同时从多个设备登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51855857/