lib/firehose/rack/consumer/web_socket.rb
# Subscribe the client to the channel on the server. Asks for
# the last sequence for clients that reconnect.
Subscribe the client to the channel on the server. Asks for
the last sequence for clients that reconnect.
Subscribe the client to the channel on the server . Asks for the last sequence for clients that reconnect .
def subscribe(channel_name, last_sequence, params)
            chan_sub = Server::ChannelSubscription.new(
              channel_name,
              @ws.env,
              params: params,
              sequence: last_sequence
            )
            deferrable   = chan_sub.next_messages
            subscription = Subscription.new(chan_sub, deferrable)
            @subscriptions[channel_name] = subscription
            deferrable.callback do |messages|
              messages.each do |message|
                send_message(
                  channel: channel_name,
                  message: message.payload,
                  last_sequence: message.sequence
                )
                Firehose.logger.debug "WS sent `#{message.payload}` to `#{channel_name}` with sequence `#{message.sequence}`"
              end
              subscribe channel_name, messages.last.sequence, params
            end
            deferrable.errback do |e|
              unless e == :disconnect
                Firehose::Server.metrics.error!(:ws_subscribe_multiplexed, channel_name)
                EM.next_tick { raise e.inspect }
              end
            end
          end
def subscribe ( channel_name , last_sequence , params ) chan_sub = Server :: ChannelSubscription . new ( channel_name , @ws . env , params : params , sequence : last_sequence ) deferrable = chan_sub . next_messages subscription = Subscription . new ( chan_sub , deferrable ) @subscriptions [ channel_name ] = subscription deferrable . callback do | messages | messages . each do | message | send_message ( channel : channel_name , message : message . payload , last_sequence : message . sequence ) Firehose . logger . debug "WS sent `#{message.payload}` to `#{channel_name}` with sequence `#{message.sequence}`" end subscribe channel_name , messages . last . sequence , params end deferrable . errback do | e | unless e == :disconnect Firehose :: Server . metrics . error! ( :ws_subscribe_multiplexed , channel_name ) EM . next_tick { raise e . inspect } end end end
Subscribe the client to the channel on the server.
Subscribe the client to the channel on the server .
channel_name
<not_specific>
last_sequence
<not_specific>
params
<not_specific>