Xmpp,Strophe Js:同一用户的多个活动连接 [英] Xmpp, Strophe Js : Multiple active connections for same user

查看:185
本文介绍了Xmpp,Strophe Js:同一用户的多个活动连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用xmpp + openfire + strophe实现了网络聊天.在同一个openfire和xmpp服务器上,我们也开发了IOS chat.

I have implemented web chat using xmpp + openfire + strophe. On the same openfire and xmpp server we have developed IOS chat as well.

我正面临以下问题.

假设用户A在IOS应用程序中以xmpp连接,而用户A与用户B聊天. 现在,同一用户A使用strophe通过网络聊天连接到xmpp,而用户B将消息发送给用户A,则用户A仅在网络聊天连接中有消息.

Lets say a user A connected in xmpp in IOS app and user A chat with user B. Now same user A connect with web chat to xmpp using strophe and user B sends the message to user A then User A will have message in the web chat connection only.

现在,用户A在IOS中与xmpp连接,并且用户B发送消息,那么用户A将仅在IOS应用程序中获取消息,而不是在Web聊天中.

Now user A connect with xmpp in IOS and User B send message then User A will get message in IOS app only, not in web chat.

用户A是否有可能在所有已创建的连接处都显示消息?

Is it possible then user A will have message at all the connections which are created?

一个用户是否可能具有多个xmpp连接,并且所有连接都能够向另一个用户发送消息并能够在该用户的所有连接处获取消息?

Does it possible a User will have multiple xmpp connections and all the connections are able to send message to another user and able to get messages at all the connections of the user?

您能帮助我在Strophe Js和IOS中解决此问题吗?

Can you please help me to solve this issue in Strophe Js and IOS?

推荐答案

您可以通过设置其他资源(

You can manage it by setting different RESOURCES (https://wiki.xmpp.org/web/Jabber_Resources). Each device must declare a different Resource ("myPc", "android", "iphone", "ipad", "Spark", it's just an arbitrary String).

必须将Openfire配置为管理多个资源(服务器->服务器设置->资源策略).

Openfire must be configurated to manage multiple Resources (Server -> Server Settings -> Resource Policy).

Openfire还有一个基于优先级的传递系统,该系统选择优先级最高的资源并仅向其发送消息. (很好的讨论: https://community.igniterealtime.org/thread/53377 ) 通过设置属性来启用:

Openfire has also a priority-based delivery system that chooses the highest priority resource and send only to it the message. (a nice discussion: https://community.igniterealtime.org/thread/53377) Enable by setting the property:

route.all-resources

true

根据这个问题,您还需要 Openfire服务器,多重连接,route.all-resources不工作

According to this question, you need also Openfire server, multiple connection, route.all-resources doesn't work

route.really-all-resources

设置为

true

如何做:

  • 通过数据库,在"ofProperty"表上添加两个属性
  • 或通过openfire Web客户端->服务器->服务器管理器->系统 属性(在页面底部添加).
  • by database, adding on "ofProperty" table both properties
  • or by openfire web client -> Server -> Server Manager -> System Property (add in on bottom of the page).

请记住

  1. 在线状态具有优先级(介于-128和128之间的数字),默认 是1.仔细更改此数字.
  2. 当然,客户端在发送邮件时必须包括资源 信息(这是您的情况,但请注意保持正确的信息 行为)
  1. Presence has a priority (a number between -128 and 128), default it's 1. Carefully change this number.
  2. Of course clients must not include the resource while sending a message (it's your case but pay attention to keep the right behaviour)

很抱歉,但我不知道如何在Strophe.js中分配资源名称,正如在某些示例中看到的那样,程序员只是将其手动添加为字符串concat(登录时为user@server/resource)

I'm sorry about but I don't know how to assign a Resource name in Strophe.js as I see in some examples, programmers just add it manually as string concat (user@server/resource while login)

这篇关于Xmpp,Strophe Js:同一用户的多个活动连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆