diff options
| author | Rafael H. Schloming <rhs@apache.org> | 2007-03-07 17:13:02 +0000 |
|---|---|---|
| committer | Rafael H. Schloming <rhs@apache.org> | 2007-03-07 17:13:02 +0000 |
| commit | 6dbcf1d2ef68c8bf2b0032287bf71af8b002e35e (patch) | |
| tree | 5c2411ae8c9af50f952eab48a870d4ddd9357448 /ruby/qpid/client.rb | |
| parent | c4d2e2a327175ad1703639e42363e8b4479ce0c0 (diff) | |
| download | qpid-python-6dbcf1d2ef68c8bf2b0032287bf71af8b002e35e.tar.gz | |
added test harness, tests, and a few missing pieces of implementation
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@515652 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'ruby/qpid/client.rb')
| -rw-r--r-- | ruby/qpid/client.rb | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/ruby/qpid/client.rb b/ruby/qpid/client.rb index 485dbf745d..f10f2e564b 100644 --- a/ruby/qpid/client.rb +++ b/ruby/qpid/client.rb @@ -24,11 +24,11 @@ require "qpid/queue" module Qpid class Client - def initialize(host, port, spec, vhost = nil) + def initialize(host, port, spec, vhost = "/") @host = host @port = port @spec = spec - @vhost = if vhost.nil?; host else vhost end + @vhost = vhost @mechanism = nil @response = nil @@ -38,6 +38,7 @@ module Qpid @mutex = Mutex.new() @closed = false + @code = nil @started = ConditionVariable.new() @conn = Connection.new(@host, @port, @spec) @@ -47,6 +48,8 @@ module Qpid attr_reader :mechanism, :response, :locale def closed?; @closed end + def closed=(value); @closed = value end + def code; @code end def wait() @mutex.synchronize do @@ -85,6 +88,12 @@ module Qpid def channel(id) return @peer.channel(id) end + + def close(msg = nil) + @closed = true + @code = msg + @peer.close() + end end class ClientDelegate @@ -104,6 +113,23 @@ module Qpid ch.connection_tune_ok(*msg.fields) @client.signal_start() end + + def connection_close(ch, msg) + puts "CONNECTION CLOSED: #{msg.args.join(", ")}" + @client.close(msg) + end + + def channel_close(ch, msg) + puts "CHANNEL[#{ch.id}] CLOSED: #{msg.args.join(", ")}" + ch.channel_close_ok() + ch.close() + end + + def basic_deliver(ch, msg) + queue = @client.queue(msg.consumer_tag) + queue << msg + end + end end |
