filmov
tv
Rails 7 E109 Live vistor count. ActionCable, Turbo Broadcasts, Kredis

Показать описание
Let's add "Live count for total website visitors" and "Live count for visitors inside a room".
Importantly, we will not deal with user REGISTRATION to identify a visitor. One browser session = one unique visitor with a session_id.
We will use "turbo_stream_from" to plug into an ActionCable Channel and track websocket subscriptions and un-subscriptions.
Whenever a user "subscribes", we will add his browser session_id to a Kredis array.
We will Broadcast the updated Kredis array COUNT to everybody subscribed to the channel.
Sounds quite complex, but I still think of it as a very low-code solution.
0:00 Demo - Track visitors on a website and in a room
1:51 Track all website visitors with Kredis and ActionCable
12:25 Update live vistiors count with Turbo Stream Broadcasts
14:29 Track visitors in a Room
20:40 Summary and final demo
Importantly, we will not deal with user REGISTRATION to identify a visitor. One browser session = one unique visitor with a session_id.
We will use "turbo_stream_from" to plug into an ActionCable Channel and track websocket subscriptions and un-subscriptions.
Whenever a user "subscribes", we will add his browser session_id to a Kredis array.
We will Broadcast the updated Kredis array COUNT to everybody subscribed to the channel.
Sounds quite complex, but I still think of it as a very low-code solution.
0:00 Demo - Track visitors on a website and in a room
1:51 Track all website visitors with Kredis and ActionCable
12:25 Update live vistiors count with Turbo Stream Broadcasts
14:29 Track visitors in a Room
20:40 Summary and final demo
Комментарии