Search code examples
ruby-on-railsactioncablerails-activejob

Multiple chatrooms on one page requires multiple channels or not?


I am building message chatrooms part of the app and I was wondering do I need multiple channels. I am going to have specifically 4 chatrooms per URL.


Solution

  • It does not necessarily need 4 different actioncable channels. You can also send an identifier in the actioncable message and make sure your frontend processes it correctly.

    Both architectures make sense, depending on whether your chatrooms have different goals or not. If they are all the same, I would advise you to have only one channel so that you can refactor things like authentication, message transformations, etc.