android - 在 Ejabberd/XMPP 中同时禁用多个设备的用户登录
问题描述
环境:
Ejabberd 版本: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)
很高兴听到您对此的解决方案/想法。提前致谢。
解决方案
来自 XMPP 规范:
“如果已经有同名的活动资源,服务器必须(1)终止活动资源并允许新请求的会话,或(2)禁止新请求的会话并保持活动资源。服务器所做的这些取决于实施,尽管建议实施案例#1。”
更多信息在这里https://xmpp.org/rfcs/rfc3921.html#session
因此,您当前的方案是推荐的方案。
但是,我很快检查了 ejabberd src 代码,发现它可以以某种方式配置(closeold -> closenew)
https://github.com/processone/ejabberd/blob/master/src/ejabberd_c2s.erl#L964
https://github.com/processone/ejabberd/blob/master/src/ejabberd_c2s.erl#L873
我不是Erlang专家,但是貌似可以通过修改源码来实现
推荐阅读
- dialogflow-es - 制作代理后缺少 Dialogflow 集成服务帐户
- docker - 从 8081 端口卸载 nginx 服务器
- flutter - 错误“无法在初始化程序中访问实例成员 'widget'。”
- firebase - 颤动底部导航器手势检测器不起作用
- python - 网络抓取的 Python while 循环错误,相同的数据出现 5 次
- jquery - 无法使用 jQuery validate 验证我的表单
- python - Python:从字典中提取多个值
- reactjs - 学生名单点击并重定向到页面反应
- html - 如何在 html iframe 中使用 heroku 应用程序?
- c++ - 在系统上安装 pmdk 库后,程序给出错误“致命错误:libpmemkv.hpp:没有这样的文件或目录”