Class: Presence::HTTPNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/presence/listeners/http_notifier.rb

Overview

Scanner listener that sends an HTTP notification whenever a new client connects or when a connected client disconnects. This listener is intended to be used with Presence::Tracker when scanning in a loop.

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ HTTPNotifier

Returns a new instance of HTTPNotifier.



11
12
13
14
15
16
17
# File 'lib/presence/listeners/http_notifier.rb', line 11

def initialize(options = nil)
  options ||= {}
  @options = {
    use_ssl: false,
    verify_mode: OpenSSL::SSL::VERIFY_PEER
  }.merge(options)
end

Instance Method Details

#listener_registered(l, scanner) ⇒ Object



19
20
21
# File 'lib/presence/listeners/http_notifier.rb', line 19

def listener_registered(l, scanner)
  @scanner ||= scanner
end

#mac_connected(mac, ip) ⇒ Object



23
24
25
# File 'lib/presence/listeners/http_notifier.rb', line 23

def mac_connected(mac, ip)
  notify(:mac_connected, { mac: mac, ip: ip })
end

#mac_disconnected(mac, old_ip) ⇒ Object



27
28
29
# File 'lib/presence/listeners/http_notifier.rb', line 27

def mac_disconnected(mac, old_ip)
  notify(:mac_disconnected, { mac: mac, ip: old_ip })
end