| 1 | require 'xmpp4r' |
|---|
| 2 | |
|---|
| 3 | ARG_HOSTNAME = ENV["SNIPER_HOSTNAME"] || "localhost" |
|---|
| 4 | ARG_USERNAME = ENV["SNIPER_ID"] || "sniper" |
|---|
| 5 | ARG_PASSWORD = ENV["SNIPER_PASSWORD"] || "sniper" |
|---|
| 6 | ARG_ITEM_ID = ENV["SNIPER_ITEM_ID"] || "item-54321" |
|---|
| 7 | |
|---|
| 8 | AUCTION_RESOURCE = "Auction" |
|---|
| 9 | |
|---|
| 10 | class 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 |
|---|
| 29 | end |
|---|
| 30 | |
|---|
| 31 | Application.new.start |
|---|
| 32 | sleep 500 |
|---|