使用会话 PID 和会话 PID 提取 SID联合ID
我正在尝试找到一种使用 PID 和 JID 提取 bosh 会话(ejabberd)的 SID 的方法,以便我可以在 ejabberd_sm:unset_presence
中使用它,我到处搜索但找不到方法去做它。
基本上,我已经使用 Ejabberd 和 Strope 构建了一个聊天系统,我想要实现的是,当用户按下一页上的离线按钮时,与该 JID 关联的所有会话都需要离线,我已经使用 提取了 PID ejabberd_sm:get_session_pid
但找不到提取 SID 的方法。我也尝试过SID!断开连接
但这会完全断开用户的连接,这是我不想要的。
如果有人做过此类工作,请帮助我,也欢迎实现此类工作的其他想法。
谢谢
I am trying to find a way for extracting SID of a bosh session (ejabberd) using PID and JID so that I can use it in ejabberd_sm:unset_presence
, I have searched everywhere but can't find a way to do it.
Basically, I have built a chat system using Ejabberd and Strophe and what I am trying to achieve is when user press offline button on one page all the sessions associated with that JID needs to go offline, I have extraced the PID by using ejabberd_sm:get_session_pid
but can't find a way to extrct SID. I have also tried SID ! Disconnect
but that disconnects the user completely which I don't want.
If anybody has done this kind of work please help me, other ideas for implementing such thing are also welcome.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对此进行了一些挖掘,这就是交易。您从
ejabberd_sm:get_session_pid
返回的值是该用户会话的ejabberd_c2s
进程。但ejabberd_c2s
完全不知道BOSH。您真正需要的是用户的 BOSH 会话 ID,它由模块ejabberd_http_bind
维护。据我所知,没有“好的”方法可以从
ejabberd_c2s
中获取此信息。我最终做了这样的事情:现在,最终给您的只是
ejabberd_http_bind
进程的 PID。你可以再次重复整个肮脏的事情,但在这里我建议做一点欺骗:正如你所看到的,这是非常丑陋的。更好的方法是修改
ejabberd_c2s
以接受新类型的sync_event
,它将返回套接字信息,并同样修改ejabberd_http_bind
接受类似的事件以返回 SID。当然,这两个都将被包装在公共函数中,这些函数在内部进行相关的 gen_fsm 调用。话虽如此,我不确定 BOSH SID 到底能给您带来什么好处。特别是,我不确定在这种情况下“离线”和“断开连接”之间有什么区别。但无论如何,这就是您获取信息的方式。
I did some digging on this and here's the deal. The value you get back from
ejabberd_sm:get_session_pid
is theejabberd_c2s
process for that user's session. Butejabberd_c2s
is entirely unaware of BOSH. What you really need is the user's BOSH session ID which is maintained by the moduleejabberd_http_bind
.As best I can tell there's no "nice" way to get this information out of
ejabberd_c2s
. I ended up doing something like this:Now, all that gives you at the end of the day is a PID for the
ejabberd_http_bind
process. You can repeat the whole sordid business again, but here I suggest cheating a little:As you can see, this is horrendously ugly. The nicer way to do it would be to modify
ejabberd_c2s
to accept a new type ofsync_event
that would return the socket information, and likewise modifyejabberd_http_bind
to accept a similar sort of event to return the SID. And of course, both of these would be wrapped in public functions that internally make the relevantgen_fsm
calls.All that said, I'm not sure what good the BOSH SID is really going to do you. And in particular, I'm not sure what the difference between "go offline" and "disconnect" is in this scenario. But anyway, that's how you get the information.