Class: ONVIF::Client
- Inherits:
-
Object
- Object
- ONVIF::Client
- Defined in:
- lib/ruby_onvif_client/client.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
- #send(data) ⇒ Object
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 |
# File 'lib/ruby_onvif_client/client.rb', line 7 def initialize @options = { connect_timeout: 5, }.merge() end |
Instance Method Details
#send(data) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ruby_onvif_client/client.rb', line 13 def send data puts "send data to #{@options} ", data = { connect_timeout: @options[:connect_timeout] } = { body: data } http = EventMachine::HttpRequest.new( @options[:address], ).post() http.errback { yield false, {} } http.callback do puts "=========================" puts "receive message =>", http.response puts "=========================" if http.response_header.status != 200 yield false, {header: http.response_header} else #nori = Nori.new(:strip_namespaces => true) yield true, { header: http.response_header, #content: nori.parse(http.response) content: http.response } end end end |