mirror of
https://github.com/onyx-and-iris/obsws-ruby.git
synced 2026-04-18 21:43:32 +00:00
assign client updater methods as base lambdas
This commit is contained in:
@@ -70,20 +70,18 @@ module OBSWS
|
||||
kwargs[:subs] ||= SUBS::LOW_VOLUME
|
||||
@base_client = Base.new(**kwargs)
|
||||
LOGGER.info("#{self} succesfully identified with server")
|
||||
@base_client.add_observer(self)
|
||||
@base_client.updater = ->(op_code, data) {
|
||||
if op_code == Mixin::OPCodes::EVENT
|
||||
event = data[:eventType]
|
||||
data = data.fetch(:eventData, {})
|
||||
notify_observers(event, Mixin::Data.new(data, data.keys))
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def to_s
|
||||
self.class.name.split("::").last(2).join("::")
|
||||
end
|
||||
|
||||
def update(op_code, data)
|
||||
if op_code == Mixin::OPCodes::EVENT
|
||||
event = data[:eventType]
|
||||
data = data.key?(:eventData) ? data[:eventData] : {}
|
||||
notify_observers(event, Mixin::Data.new(data, data.keys))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user