Class: BenchmarkChannel
- Inherits:
-
ApplicationCable::Channel
- Object
- ActionCable::Channel::Base
- ApplicationCable::Channel
- BenchmarkChannel
- Defined in:
- lib/anyt/dummy/application.rb
Overview
BenchmarkChannel is useful when running Rails app only or RPC only
Instance Method Summary collapse
Instance Method Details
#broadcast(data) ⇒ Object
66 67 68 69 70 |
# File 'lib/anyt/dummy/application.rb', line 66 def broadcast(data) ActionCable.server.broadcast "all#{stream_id}", data data["action"] = "broadcastResult" transmit data end |
#counter(data) ⇒ Object
72 73 74 75 |
# File 'lib/anyt/dummy/application.rb', line 72 def counter(data) num = data.fetch("num", 100).to_i num.times { ActionCable.server.broadcast "all", {text: "Count: #{_1}"} } end |
#echo(data) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/anyt/dummy/application.rb', line 57 def echo(data) puts "ECHO: #{data.inspect}" if data["verbose"] delay = data.fetch("delay", ECHO_DELAY).to_f if delay > 0 sleep delay end transmit data end |
#subscribed ⇒ Object
53 54 55 |
# File 'lib/anyt/dummy/application.rb', line 53 def subscribed stream_from "all#{stream_id}" end |