Class: Devformance::MetricsChannel

Inherits:
ApplicationCable::Channel show all
Defined in:
app/channels/devformance/metrics_channel.rb

Instance Method Summary collapse

Instance Method Details

#subscribedObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/channels/devformance/metrics_channel.rb', line 3

def subscribed
  case params[:stream_type]
  when "run"
    run_id = params[:run_id]
    stream_from "devformance:run:#{run_id}" if run_id.present?
  when "file"
    file_key = params[:file_key]
    run_id   = params[:run_id]
    if file_key.present? && run_id.present?
      stream_from "devformance:file:#{file_key}:#{run_id}"
    end
  else
    stream_from "devformance:metrics"
  end
end

#unsubscribedObject



19
20
21
# File 'app/channels/devformance/metrics_channel.rb', line 19

def unsubscribed
  stop_all_streams
end