-
-
Save mojodna/22224 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby | |
require '/Users/mattb/Work/Dopplr/code/dopplr/config/environment' | |
require 'fire_hydrant' | |
config = YAML.load(File.read("fire_hydrant.yml")) | |
hydrant = FireHydrant.new(config, false) | |
hydrant.jack!(OAuthPubSubJack) | |
hydrant.on_startup do | |
defer :subscribed, 0 do | |
begin | |
Identity.find(:all, :conditions => ["service = 'fireeagle' and identifier is not null"]).map { |i| | |
puts i.identifier | |
@oauth_token = OAuth::Token.new(i.identifier, i.extra[:secret]) | |
[i, pubsub.subscribe_to("/api/0.1/user/#{@oauth_token.token}", @oauth_consumer, @oauth_token)] | |
} | |
rescue Jabber::ServerError => e | |
puts e | |
end | |
end | |
# define here or as hydrant.subscriptions_received | |
def subscribed(subs) | |
subs.each { |identity, subscription| | |
if subscription.subscription == :subscribed | |
puts "#{identity.traveller.name}: Subscribe successful." | |
else | |
puts "#{identity.traveller.name}: Subscribe failed!" | |
end | |
} | |
end | |
end | |
hydrant.run! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment