class OBS::WebSocket::EventDispatcher
Public Class Methods
new()
click to toggle source
# File lib/obs/websocket.rb, line 147 def initialize @listeners = Hash.new {|h, k| h[k] = []} end
Public Instance Methods
dispatch(update_type, payload)
click to toggle source
# File lib/obs/websocket.rb, line 155 def dispatch(update_type, payload) event = Protocol::Event.create(update_type, payload).freeze @listeners[update_type].each do |(executor, listener)| Concurrent::Promises.future_on(executor, event, &listener).run end end
register(executor, type, listener)
click to toggle source
# File lib/obs/websocket.rb, line 151 def register(executor, type, listener) @listeners[type].push([executor, listener]) end