Projects

Ticket #503: connect.rb

File connect.rb, 0.7 KB (added by marick@…, 2 years ago)
Line 
1require 'xmpp4r'
2
3ARG_HOSTNAME = ENV["SNIPER_HOSTNAME"] || "localhost"
4ARG_USERNAME =  ENV["SNIPER_ID"] || "sniper"
5ARG_PASSWORD = ENV["SNIPER_PASSWORD"] || "sniper"
6ARG_ITEM_ID = ENV["SNIPER_ITEM_ID"] || "item-54321"
7
8AUCTION_RESOURCE = "Auction"
9
10class Application
11  include Jabber
12 
13  def start
14    puts "==== Ready for JID"
15
16    jid_string = "#{ARG_USERNAME}@localhost/#{AUCTION_RESOURCE}"
17    puts jid_string
18    jid = JID::new(jid_string)
19    puts "JID: #{jid}"
20    cl = Client::new(jid)
21    result = cl.connect
22    puts "connection result = #{result}"
23    result = cl.auth(ARG_PASSWORD)
24    puts "auth result: #{result}"
25
26
27    puts "==== Starting..."
28  end
29end
30
31Application.new.start
32sleep 500