summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-10-10 14:17:18 -0600
committermo khan <mo@mokhan.ca>2014-10-10 14:17:22 -0600
commit453287880497ed5ae0c9ba796b9f8e1b15bc29cb (patch)
tree41415f8a74d44da1a714969490040297e3e8ab32
parent13fd09db3b103bce6d59515b7571897177216546 (diff)
use REPL to blast out chat messages.
-rw-r--r--lib/6-chit-chat/publish.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/6-chit-chat/publish.rb b/lib/6-chit-chat/publish.rb
index e21cb3f..e899fdc 100644
--- a/lib/6-chit-chat/publish.rb
+++ b/lib/6-chit-chat/publish.rb
@@ -9,9 +9,15 @@ connection.start
channel = connection.create_channel
exchange = channel.topic("chitchat")
username = `'whoami'`.chomp!
-message = ARGV.empty? ? "Hi!" : ARGV.join(" ")
-exchange.publish(message, routing_key: username)
-puts " [x] Sent #{username}:#{message}"
+begin
+ print "> "
+ while message = gets do
+ exchange.publish(message, routing_key: username)
+ puts " [x] Sent #{username}:#{message}"
+ print "> "
+ end
+rescue
+ connection.close
+end
-connection.close