diff options
author | Rafael H. Schloming <rhs@apache.org> | 2006-09-29 14:54:37 +0000 |
---|---|---|
committer | Rafael H. Schloming <rhs@apache.org> | 2006-09-29 14:54:37 +0000 |
commit | ce57f0694a13529ab6feb8d10a7f4c8935368bb0 (patch) | |
tree | 87dcebe88c2bfc5902804bebc1405d019ffe29f9 /ruby/client.rb | |
parent | 3fedfb514c3d2ce6b9cb02a30465b6bfd3a37cf2 (diff) | |
download | qpid-python-ce57f0694a13529ab6feb8d10a7f4c8935368bb0.tar.gz |
moved ruby code into a qpid package
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@451317 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'ruby/client.rb')
-rw-r--r-- | ruby/client.rb | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/ruby/client.rb b/ruby/client.rb deleted file mode 100644 index f8535dca6f..0000000000 --- a/ruby/client.rb +++ /dev/null @@ -1,106 +0,0 @@ -# -# Copyright (c) 2006 The Apache Software Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require "peer" -require "thread" -require "queue" - -module Qpid - - class Client - def initialize(host, port, spec, vhost = nil) - @host = host - @port = port - @spec = spec - @vhost = if vhost.nil?; host else vhost end - - @mechanism = nil - @response = nil - @locale = nil - - @queues = {} - @mutex = Mutex.new() - - @closed = false - @started = ConditionVariable.new() - - @conn = Connection.new(@host, @port, @spec) - @peer = Peer.new(@conn, ClientDelegate.new(self)) - end - - attr_reader :mechanism, :response, :locale - - def closed?; @closed end - - def wait() - @mutex.synchronize do - @started.wait(@mutex) - end - raise EOFError.new() if closed? - end - - def signal_start() - @started.broadcast() - end - - def queue(key) - @mutex.synchronize do - q = @queues[key] - if q.nil? - q = Queue.new() - @queues[key] = q - end - return q - end - end - - def start(response, mechanism="AMQPLAIN", locale="en_US") - @response = response - @mechanism = mechanism - @locale = locale - - @conn.connect() - @conn.init() - @peer.start() - wait() - channel(0).connection_open(@vhost) - end - - def channel(id) - return @peer.channel(id) - end - end - - class ClientDelegate - include Delegate - - def initialize(client) - @client = client - end - - def connection_start(ch, msg) - ch.connection_start_ok(:mechanism => @client.mechanism, - :response => @client.response, - :locale => @client.locale) - end - - def connection_tune(ch, msg) - ch.connection_tune_ok(*msg.fields) - @client.signal_start() - end - end - -end |