diff options
| author | mo khan <mo@mokhan.ca> | 2014-10-10 14:17:18 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-10-10 14:17:22 -0600 |
| commit | 453287880497ed5ae0c9ba796b9f8e1b15bc29cb (patch) | |
| tree | 41415f8a74d44da1a714969490040297e3e8ab32 | |
| parent | 13fd09db3b103bce6d59515b7571897177216546 (diff) | |
use REPL to blast out chat messages.
| -rw-r--r-- | lib/6-chit-chat/publish.rb | 14 |
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 |
