Created
April 3, 2013 04:09
-
-
Save jpettersson/5298389 to your computer and use it in GitHub Desktop.
AirportEvents blog post: http://jpettersson.com/airport-events-ruby-gem/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'airport_events' | |
# Create a new Watcher instance and set up some event listeners. | |
watcher = AirportEvents::Watcher.new | |
watcher.on :connected do |ssid, date| | |
puts "Connected to #{ssid} on #{date}" | |
end | |
watcher.on :disconnected do |date| | |
puts "Disconnected on #{date}" | |
end | |
# Start the watcher, which runs in a separate Thread. | |
watcher.start | |
# Keep program alive until interrupted (For instance: CTRL + C). | |
interrupted = false | |
trap("INT") { interrupted = true } | |
while true do | |
exit if interrupted | |
sleep 0.1 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"ssid": "orca", | |
"connected_at": "2013-02-24T22:35:54+00:00", | |
"disconnected_at": "2013-02-24T22:47:38-05:00" | |
}, | |
{ | |
"ssid": "beluga", | |
"connected_at": "2013-02-24T22:48:23-05:00", | |
"disconnected_at": null | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment