2022-10-22 22:30:40 +01:00
|
|
|
module OBSWS
|
|
|
|
module Mixin
|
|
|
|
module Meta
|
2023-07-26 18:55:35 +01:00
|
|
|
include Util::String
|
2022-10-22 22:30:40 +01:00
|
|
|
|
2022-10-23 06:09:18 +01:00
|
|
|
def make_field_methods(*params)
|
2022-10-22 22:30:40 +01:00
|
|
|
params.each do |param|
|
2023-07-26 18:55:35 +01:00
|
|
|
define_singleton_method(snakecase(param.to_s)) { @resp[param] }
|
2022-10-22 22:30:40 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class MetaObject
|
|
|
|
include Mixin::Meta
|
|
|
|
|
|
|
|
def initialize(resp, fields)
|
|
|
|
@resp = resp
|
|
|
|
@fields = fields
|
2023-07-26 10:52:07 +01:00
|
|
|
make_field_methods(*fields)
|
2022-10-22 22:30:40 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def empty? = @fields.empty?
|
|
|
|
|
2023-07-26 18:55:35 +01:00
|
|
|
def attrs = @fields.map { |f| snakecase(f.to_s) }
|
2022-10-22 22:30:40 +01:00
|
|
|
end
|
|
|
|
|
2023-08-03 14:39:44 +01:00
|
|
|
# Represents a request response object
|
2023-08-29 15:45:42 +01:00
|
|
|
class Response < MetaObject; end
|
2022-10-22 22:30:40 +01:00
|
|
|
|
2023-08-03 14:39:44 +01:00
|
|
|
# Represents an event data object
|
2023-08-29 15:45:42 +01:00
|
|
|
class Data < MetaObject; end
|
2022-10-22 22:30:40 +01:00
|
|
|
|
|
|
|
module TearDown
|
2023-07-26 10:52:07 +01:00
|
|
|
def stop_driver
|
|
|
|
@base_client.stop_driver
|
2022-10-22 22:30:40 +01:00
|
|
|
end
|
2023-07-26 10:52:07 +01:00
|
|
|
|
|
|
|
alias_method :close, :stop_driver
|
2022-10-22 22:30:40 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
module OPCodes
|
|
|
|
HELLO = 0
|
|
|
|
IDENTIFY = 1
|
|
|
|
IDENTIFIED = 2
|
|
|
|
REIDENTIFY = 3
|
|
|
|
EVENT = 5
|
|
|
|
REQUEST = 6
|
|
|
|
REQUESTRESPONSE = 7
|
|
|
|
REQUESTBATCH = 8
|
|
|
|
REQUESTBATCHRESPONSE = 9
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|