Class: Bitflyer::Realtime::Client
- Inherits:
-
Object
- Object
- Bitflyer::Realtime::Client
- Defined in:
- lib/bitflyer/realtime/client.rb
Instance Method Summary collapse
-
#initialize ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bitflyer/realtime/client.rb', line 28 def initialize @pubnub = Pubnub.new(subscribe_key: Realtime::PUBNUB_SUBSCRIBE_KEY) @callback = Pubnub::SubscribeCallback.new( message: ->(envelope) { channel_name = envelope.result[:data][:subscribed_channel].gsub('lightning_', '').downcase.to_sym = envelope.result[:data][:message] send(channel_name).call() if send(channel_name) }, presence: ->(envelope) {}, status: ->(envelope) {} ) @pubnub.add_listener(callback: @callback) @pubnub.subscribe(channels: Realtime::CHANNEL_NAMES) end |