Class: Livechat::StreamChannel
- Inherits:
-
ActionCable::Channel::Base
- Object
- ActionCable::Channel::Base
- Livechat::StreamChannel
- Defined in:
- lib/livechat/channels.rb
Overview
One channel for both sides of the chat. It carries no payload of its own — a broadcast is a nudge ("something changed on this stream"); the client then refetches through the same gated endpoint it already polls, so the rendering, dedup and read-tracking logic stays in one place.
Authorization IS the signature: the server only ever signs a stream name it already let this subscriber see — the widget gets its conversation stream from the gated /conversation endpoint, an agent gets conversation and inbox streams from the (authorized) inbox pages. A subscriber that can't present a validly signed livechat: stream is rejected.
Instance Method Summary collapse
Instance Method Details
#subscribed ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/livechat/channels.rb', line 18 def subscribed stream = Livechat.verify_stream(params[:signed_stream]) if stream&.start_with?('livechat:') stream_from stream else reject end end |