简体   繁体   English

如何为动态聊天室配置Autobahn(crossbar.io)?

[英]How to configure Autobahn(crossbar.io) for dynamic chat rooms?

I love crossbar.io and how it works(personally). 我喜欢crossbar.io以及它是如何工作的(个人)。 But I would like to know how we could setup the architecture for a typical dynamic chat application using Autobahn(Crossbar.io). 但我想知道如何使用Autobahn(Crossbar.io)为典型的动态聊天应用程序设置架构。

Dynamic chat here means, individual chat room created for each url. 这里的动态聊天意味着为每个网址创建了单独的聊天室。

For example: http://www.myapplication.com/chat?roomId=123 , creates a chat room subscribing to topic "com.myapp.chat123" . 例如: http://www.myapplication.com/chat?roomId=123//www.myapplication.com/chat?roomId = 123 ,创建一个订阅主题“com.myapp.chat123”的聊天室。

http://www.myapplication.com/chat?roomId=456 , creates a chat room subscribing to topic "com.myapp.chat456" . http://www.myapplication.com/chat?roomId=456 ,创建一个订阅主题“com.myapp.chat456”的聊天室。

We need to store the chat messages in the Database for future reference, since Autobahn doesn't have message persistence. 我们需要将聊天消息存储在数据库中以供将来参考,因为高速公路没有消息持久性。

Now my questions are: 现在我的问题是:

  1. If each chat room use separate topic, then how we could subscribe for the messages in the server(since we can't subscribe using Patterns as of now) ? 如果每个聊天室使用单独的主题,那么我们如何订阅服务器中的消息(因为我们现在无法使用模式订阅)?

  2. Since we will use separate topic for each room, how we do authentication and authorization in Crossbar.io ? 由于我们将为每个房间使用单独的主题,我们如何在Crossbar.io中进行身份验证和授权?

  3. I couldn't able to find the Javascript documentation for setting the features as mentioned here . 我无法找到用于设置此处提到的功能的Javascript文档。 Where to find it ? 哪里可以找到它?

  4. In this SO answer , it was mentioned that crossbar.io provides meta-events for session join or leave on Router . 在这个SO答案中 ,有人提到crossbar.io为会话加入或离开路由器提供元事件。 Is there any way to know when user subscribes or unsubscribes to specific topic instead of Router join or leave ? 有没有办法知道用户何时订阅或取消订阅特定主题而不是路由器加入或离开?

  5. Could you explain how to configure available advanced profile features with Current version of Crossbar.io (in Javascript, browser or Node.js) ? 您能解释一下如何使用当前版本的Crossbar.io(在Javascript,浏览器或Node.js中)配置可用的高级配置文件功能吗?

  6. Could you explain about Event History feature in detail ? 你能详细解释一下事件历史功能吗? And how to configure it ? 以及如何配置它?

I'll answer your question one by one: 我将逐一回答你的问题:

  1. At least, it's your client which wants to subscribe to his topic (correct me if I misunderstand), then, you need to store a list of topic ID related to user in your database, and when your client connects to the server, you send him the list of topic ID and let him subscribe all of them. 至少,你的客户想要订阅他的主题(如果我误解,请纠正我),然后,你需要在数据库中存储与用户相关的主题ID列表,当你的客户端连接到服务器时,你发送他是主题ID列表,让他订阅所有这些。
  2. Authentication / Authorization process has nothing to do with a separate topic. 身份验证/授权过程与单独的主题无关。 You can do something like that: 你可以这样做:

    • There is two way to authenticate, anonymously and WAMP-CRA. 有两种方法可以匿名验证和WAMP-CRA。 Then, you assign a role for anonymously connected clients, and another role for authenticated client (this role can be different following the database eg: user, admin, moderator, ...) 然后,为匿名连接的客户端分配角色,为经过身份验证的客户端分配另一个角色(此角色可以跟随数据库不同,例如:user,admin,moderator,...)
    • When authenticated, subscribing to a topic needs authorization (implemented by a dynamic authorizer, you can see how to do it there: https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/authorization/router.py -- basically, it is the same, except you forget the router thing and you focus on the authorize method) 经过身份验证后,订阅主题需要授权(由动态授权程序实现,您可以在那里看到如何执行此操作: https//github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/authorization/router .py - 基本上,它是相同的,除了你忘记路由器的东西,你专注于授权方法)
    • Then, you authorize based on something like Access Control. 然后,您基于Access Control之类的东西进行授权。
  3. Unfortunately, the doc is quite outdated, you should ask for it on the Mailing List which features you want to use and how can you use them. 遗憾的是,该文档已经过时,您应该在邮件列表中询问您要使用哪些功能以及如何使用它们。
  4. As I recall, there is a meta-event on_subscribe/on_unsubscribe. 我记得,有一个元事件on_subscribe / on_unsubscribe。
  5. Advanced features can be configured in the config file of Crossbar, they can be also an argument passed to publish/subscribe/call/register calls. 可以在Crossbar的配置文件中配置高级功能,它们也可以是传递给发布/订阅/调用/注册调用的参数。
  6. I'm not a core developer of Autobahn, but as much as I understood, it is a feature that give you a way to get all previous published data from a topic (X last ones, since a TIMESTAMP, after a ID). 我不是Autobahn的核心开发人员,但据我所知,这是一个功能,可以让您从主题获取所有以前发布的数据(X 最后一个, 因为 TIMESTAMP, ID之后)。

I know that Autobahn is hard to follow sometimes due to the documentation, but examples can help a lot, and here there are a lot of interesting things: https://github.com/crossbario/crossbarexamples (including Authentication, MetaAPI, Patterns). 我知道由于文档的原因,高速公路有时难以遵循,但是示例可以提供很多帮助,这里有很多有趣的东西: https//github.com/crossbario/crossbarexamples (包括身份验证,MetaAPI,模式) 。

I hope that I've answered most of your questions, but yet, if there are things you don't understand, I recommend you to go to the mailing list , this is your best try, in my opinion. 我希望我已经回答了你的大部分问题,但是,如果有些事情你不明白,我建议你去邮件列表 ,这是你最好的尝试,在我看来。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM