Fixed some in the send-message example
authorMikael Hallendal <micke@imendio.com>
Fri, 11 Apr 2008 18:15:58 +0200
changeset 392 2da579e4780f
parent 391 d8b64455b5ee
child 393 1df93aba3b9a
Fixed some in the send-message example
bindings/ruby/examples/send-message.rb
--- a/bindings/ruby/examples/send-message.rb	Thu Apr 10 21:57:49 2008 +0200
+++ b/bindings/ruby/examples/send-message.rb	Fri Apr 11 18:15:58 2008 +0200
@@ -5,13 +5,13 @@
 require 'glib2'
 
 puts "Enter your JID: "
-jid = gets.strip
+jid = gets.chomp
 
 puts "Enter connect host: "
-host = gets.strip
+host = gets.chomp
 
 puts "Enter your password: "
-password = gets.strip
+password = gets.chomp
 
 if /(.+)@(.+)/ =~ jid
   login = $1
@@ -37,21 +37,22 @@
       unless auth_result
         puts "Failed to authenticate"
       end
-      recipient = authenticated_cb(conn)
+      authenticated_cb(conn)
       main_loop.quit
     end
   else
     puts "Failed to connect"
+    main_loop.quit
   end
 end
 
 def authenticated_cb(conn)
   puts "Authenticated!"
   puts "Who do you want to message: "
-  recipient = gets.strip
+  recipient = gets.chomp
   
   puts "Enter message: "
-  body = gets.strip
+  body = gets.chomp
   
   m = LM::Message.new(recipient, LM::MessageType::MESSAGE)
   m.node.add_child('body', body)
@@ -59,9 +60,9 @@
   conn.send(m)
   conn.close
   
-  recipient
+  puts "Message sent to #{recipient}"
 end
 
 main_loop.run
 
-puts "Message sent to #{recipient}"
+puts "Quitting"