diff options
| author | mo khan <mo@mokhan.ca> | 2014-10-10 14:06:48 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-10-10 14:06:48 -0600 |
| commit | 411ff5e050d64bf78ab3985bf66d3ac30a70bd63 (patch) | |
| tree | 7fd19da804f0810ec5be30e5e194f9155d40c251 | |
| parent | bb9fd9eb612d80d639aa526a8881612cd355c015 (diff) | |
add chat client example.
| -rw-r--r-- | lib/6-chit-chat/publish.rb | 2 | ||||
| -rw-r--r-- | lib/6-chit-chat/subscribe.rb | 7 |
2 files changed, 3 insertions, 6 deletions
diff --git a/lib/6-chit-chat/publish.rb b/lib/6-chit-chat/publish.rb index 0179dce..e21cb3f 100644 --- a/lib/6-chit-chat/publish.rb +++ b/lib/6-chit-chat/publish.rb @@ -3,7 +3,7 @@ require "bunny" -connection = Bunny.new +connection = Bunny.new(host: ENV.fetch('RABBIT_HOST', 'localhost')) connection.start channel = connection.create_channel diff --git a/lib/6-chit-chat/subscribe.rb b/lib/6-chit-chat/subscribe.rb index 121de32..780cc46 100644 --- a/lib/6-chit-chat/subscribe.rb +++ b/lib/6-chit-chat/subscribe.rb @@ -3,17 +3,14 @@ require "bunny" -if ARGV.empty? - ARGV.push('#') -end - -connection = Bunny.new +connection = Bunny.new(host: ENV.fetch('RABBIT_HOST', 'localhost')) connection.start channel = connection.create_channel exchange = channel.topic("chitchat") queue = channel.queue("", exclusive: true) +ARGV.push('#') if ARGV.empty? ARGV.each do |username| queue.bind(exchange, routing_key: username) end |
