Faye to ActionCable: broadcasting modernization #1

Merged
bterkuile merged 16 commits from feat/review-improve-and-document-the-broadcasting-model into master 2026-05-17 21:23:37 +02:00
Showing only changes of commit 7c69f0a0bc - Show all commits
+5 -5
View File
@@ -11,9 +11,9 @@ module Mozo
# - Integrated with Rails authentication (cookies, sessions) # - Integrated with Rails authentication (cookies, sessions)
# - WebSocket native (no long-polling fallback needed with modern browsers) # - WebSocket native (no long-polling fallback needed with modern browsers)
# #
# Channel naming is kept compatible with the existing Faye convention: # Channel naming: accepts both Faye format and underscore format:
# /user/:uid → user_<uid> # /user/123 or /user_123 user_123
# /supplier/:sid → supplier_<sid> # /supplier/456 or /supplier_456 supplier_456
# #
# To use: # To use:
# Set Mozo.broadcaster = Mozo::Broadcaster::ActionCable.new # Set Mozo.broadcaster = Mozo::Broadcaster::ActionCable.new
@@ -21,8 +21,8 @@ module Mozo
# #
class ActionCable class ActionCable
CHANNEL_PREFIX_REMAP = { CHANNEL_PREFIX_REMAP = {
%r{^/user/(.+)$} => 'user_\1', %r{^/user[/_](.+)$} => 'user_\1',
%r{^/supplier/(.+)$} => 'supplier_\1' %r{^/supplier[/_](.+)$} => 'supplier_\1'
}.freeze }.freeze
def broadcast(message) def broadcast(message)