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(last_sequence, params)
            begin
              @subscribed = true
              @chan_sub   = Server::ChannelSubscription.new @req.path,
                                                            @ws.env,
                                                            params: params,
                                                            sequence: last_sequence
              @deferrable = @chan_sub.next_messages
              @deferrable.callback do |messages|
                messages.each do |message|
                  Firehose.logger.debug "WS sent `#{message.payload}` to `#{@req.path}` with sequence `#{message.sequence}`"
                  send_message message: message.payload, last_sequence: message.sequence
                end
                subscribe messages.last.sequence, params
              end
              @deferrable.errback do |e|
                unless e == :disconnect
                  Firehose.logger.error "WS Error: #{e}"
                  EM.next_tick { raise e.inspect }
                end
              end
            rescue Server::ChannelSubscription::Failed => e
              Firehose.logger.info "Subscription failed: #{e.message}"
              send_message error: "Subscription failed", reason: e.message
              disconnect
            end
          end
def subscribe ( last_sequence , params ) begin @subscribed = true @chan_sub = Server :: ChannelSubscription . new @req . path , @ws . env , params : params , sequence : last_sequence @deferrable = @chan_sub . next_messages @deferrable . callback do | messages | messages . each do | message | Firehose . logger . debug "WS sent `#{message.payload}` to `#{@req.path}` with sequence `#{message.sequence}`" send_message message : message . payload , last_sequence : message . sequence end subscribe messages . last . sequence , params end @deferrable . errback do | e | unless e == :disconnect Firehose . logger . error "WS Error: #{e}" EM . next_tick { raise e . inspect } end end rescue Server :: ChannelSubscription :: Failed => e Firehose . logger . info "Subscription failed: #{e.message}" send_message error : "Subscription failed" , reason : e . message disconnect end end
Subscribe the client to the channel on the server.
Subscribe the client to the channel on the server .
last_sequence
<not_specific>
params
<not_specific>