Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I love crossbar.io and how it works(personally). But I would like to know how we could setup the architecture for a typical dynamic chat application using 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=456 , creates a chat room subscribing to topic "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 ?

  3. I couldn't able to find the Javascript documentation for setting the features as mentioned here. 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. 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) ?

  6. Could you explain about Event History feature in detail ? And how to configure it ?

like image 440
Kamalakannan J Avatar asked Jan 21 '15 21:01

Kamalakannan J


1 Answers

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.
  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. Then, you assign a role for anonymously connected clients, and another role for authenticated client (this role can be different following the database e.g: 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)
    • Then, you authorize based on something like 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.
  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.
  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).

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).

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.

like image 60
Raito Avatar answered Oct 24 '22 10:10

Raito