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

I like crossbar.io and how it works (personally). But I would like to know how we could configure the architecture for a typical dynamic chat application using Autobahn (Crossbar.io).

Dynamic chat here means that a separate chat is created for each URL.

For example: http://www.myapplication.com/chat?roomId=123 creates a chat site that subscribes to "com.myapp.chat123" .

http://www.myapplication.com/chat?roomId=456 creates a chat site that subscribes to "com.myapp.chat456" .

We need to save chat messages in the database for future use, since Autobahn does not support message transfer.

Now my questions are:

  • If a separate section is used in each chat room, then how can we subscribe to messages on the server (since we cannot subscribe using templates at the moment)?

  • Since we will use a separate section for each room, how do we perform authentication and authorization in Crossbar.io?

  • I could not find the Javascript documentation for installing functions, as mentioned here . Where to find him?

  • In this SO answer, it was pointed out that crossbar.io provides meta-events for a session connection or left on the router . Is there a way to find out when a user is subscribing or not subscribing to a specific topic , but is not connecting or leaving Router?

  • Could you explain how to configure the available advanced profile features with the current version of Crossbar.io (in Javascript, browser or Node.js)?

  • Could you tell in detail about the history of events ? And how to configure it?

+5
source share
1 answer

I will answer your question one by one:

  • At least this is your client who wants to subscribe to his topic (correct me if I misunderstood), then you need to keep a list of topic identifiers related to the user in your database, and when your client connects to the server, you send give him a list of topic identifiers and give him a subscription to all of them.
  • The authentication / authorization process has nothing to do with a single topic. You can do something like this:

    • There are two authentication methods, anonymously and WAMP-CRA. Then you assign a role for anonymous clients and another role for an authenticated client (this role may differ from the database, for example: user, administrator, moderator, ...)
    • For authentication, subscribing to a topic requires authorization (implemented by a dynamic authorizer, you can see how to do it: https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/authorization/router.py - basically , this is the same thing, except that you forget about the operation of the router and focus on the authorization method).
    • Then you log in based on something like access control.
  • Unfortunately, the document is quite outdated, you have to ask it on the mailing list, what features you want to use, and how you can use them.
  • As far as I remember, there is a meta event on_subscribe / on_unsubscribe.
  • Advanced functions can be configured in the Crossbar configuration file, they can also be an argument passed to publish / sign / call / register calls.
  • I am not the main developer of Autobahn, but as I understand it, this is a function that gives you the opportunity to get all the previous published data from the topic (last X, starting at TIMESTAMP, after the ID).

I know that Autobahn is difficult to follow sometimes because of the documentation, but the examples can help a lot and there are many interesting things here: https://github.com/crossbario/crossbarexamples (including authentication, MetaAPI, templates).

I hope that I answered most of your questions, but if there are things that you don’t understand, I recommend you go to the mailing list , this is your best attempt, in my opinion.

+3
source

Source: https://habr.com/ru/post/1211655/


All Articles