Skip to content

Commit

Permalink
Optionally show online status
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Riedel committed Jun 20, 2010
1 parent 2bb4cb1 commit fda3f95
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/bullet/presenter/xmpp.rb
Expand Up @@ -10,7 +10,6 @@ def self.active?
end

def self.out_of_channel( notice )
Rails.logger.debug "XMPP: out-of-channel #{notice.inspect}"
return unless active?
notify( notice.full_notice )
end
Expand All @@ -21,6 +20,7 @@ def self.setup_connection( xmpp_information )
@receiver = xmpp_information[:receiver]
@password = xmpp_information[:password]
@account = xmpp_information[:account]
@show_online_status = xmpp_information[:show_online_status]

connect
rescue MissingSourceFile
Expand All @@ -30,22 +30,26 @@ def self.setup_connection( xmpp_information )

private
def self.connect
Rails.logger.debug "Connecting to xmpp server..."
jid = Jabber::JID.new( @account )
@xmpp = Jabber::Client.new( jid )
@xmpp.connect
@xmpp.auth( @password )
Rails.logger.debug "Connected to xmpp server"
@xmpp.send( presence_status ) if @show_online_status
end

def self.notify( message )
message = Jabber::Message.new( @receiver, message ).
set_type( :normal ).
set_id( '1' ).
set_subject( 'Bullet Notification' )
Rails.logger.debug "XMPP: Sending message: #{message.inspect}"
@xmpp.send( message )
Rails.logger.debug "XMPP: Message sent."
end

def self.presence_status
project_name = Rails.root.basename.to_s.camelcase
time = Time.now

Jabber::Presence.new.set_status( "Bullet in project '#{project_name}' started on #{time}" )
end
end
end
Expand Down

0 comments on commit fda3f95

Please sign in to comment.