Class: OBSWS::Events::Client
- Inherits:
-
Object
- Object
- OBSWS::Events::Client
- Includes:
- Director, 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 Director
#deregister, #fire, #observers, #on, #register
Methods included from Logging
Constructor Details
#initialize(**kwargs) ⇒ Client
Returns a new instance of Client.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/obsws/event.rb', line 63 def initialize(**kwargs) kwargs[:subs] ||= SUBS::LOW_VOLUME @base_client = Base.new(**kwargs) unless @base_client.identified.state == :identified err_msg = @base_client.identified. logger.error(err_msg) raise OBSWSConnectionError.new(err_msg) end 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, {}) fire(event, Mixin::Data.new(data, data.keys)) end } end |
Instance Method Details
#to_s ⇒ Object
87 88 89 |
# File 'lib/obsws/event.rb', line 87 def to_s self.class.name.split("::").last(2).join("::") end |