Class: OBSWS::Events::Client
- Inherits:
-
Object
- Object
- OBSWS::Events::Client
- Includes:
- Callbacks, Logging, Mixin::OPCodes, Mixin::TearDown
- Defined in:
- lib/obsws/event.rb
Constant Summary
Constants included from Mixin::OPCodes
Mixin::OPCodes::EVENT, Mixin::OPCodes::HELLO, Mixin::OPCodes::IDENTIFIED, Mixin::OPCodes::IDENTIFY, Mixin::OPCodes::REIDENTIFY, Mixin::OPCodes::REQUEST, Mixin::OPCodes::REQUESTBATCH, Mixin::OPCodes::REQUESTBATCHRESPONSE, Mixin::OPCodes::REQUESTRESPONSE
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ Client
constructor
A new instance of Client.
- #to_s ⇒ Object
Methods included from Mixin::TearDown
Methods included from Callbacks
#add_observer, #observers, #remove_observer
Methods included from Util::String
Methods included from Logging
Constructor Details
#initialize(**kwargs) ⇒ Client
Returns a new instance of Client.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/obsws/event.rb', line 71 def initialize(**kwargs) kwargs[:subs] ||= SUBS::LOW_VOLUME @base_client = Base.new(**kwargs) logger.info("#{self} successfully identified with server") rescue Errno::ECONNREFUSED, WaitUtil::TimeoutError => e msg = "#{e.class.name}: #{e.}" logger.error(msg) raise OBSWSConnectionError.new(msg) else @base_client.updater = ->(op_code, data) { if op_code == Mixin::OPCodes::EVENT logger.debug("received: #{data}") event = data[:eventType] data = data.fetch(:eventData, {}) notify_observers(event, Mixin::Data.new(data, data.keys)) end } end |
Instance Method Details
#to_s ⇒ Object
90 91 92 |
# File 'lib/obsws/event.rb', line 90 def to_s self.class.name.split("::").last(2).join("::") end |