You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by mc...@apache.org on 2015/05/20 17:29:03 UTC
[10/25] qpid-proton git commit: PROTON-799: Added the Endpoint class
to the Ruby engine APIs.
PROTON-799: Added the Endpoint class to the Ruby engine APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/0f27065a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/0f27065a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/0f27065a
Branch: refs/heads/ruby-engine-apis
Commit: 0f27065a4a84f1b468bb6c6ad09aa6703f60ff91
Parents: 8159151
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Mon Jan 19 10:20:33 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Wed May 20 11:11:41 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/endpoint.rb | 115 +++++++++++++++++++++++
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
2 files changed, 116 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f27065a/proton-c/bindings/ruby/lib/core/endpoint.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/endpoint.rb b/proton-c/bindings/ruby/lib/core/endpoint.rb
new file mode 100644
index 0000000..cbf1015
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/core/endpoint.rb
@@ -0,0 +1,115 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+#++
+
+module Qpid::Proton
+
+ # Endpoint is the parent classes for Link and Session.
+ #
+ # It provides a namespace for constant values that relate to the current
+ # state of both links and sessions.
+ #
+ # @example
+ #
+ # conn = Qpid::Proton::Connection.new
+ # puts "Local connection flags : #{conn.state || Qpid::Proton::Endpoint::LOCAL_MASK}"
+ # puts "Remote connection flags: #{conn.state || Qpid::Proton::Endpoint::REMOTE_MASK}"
+ #
+ class Endpoint
+
+ # The local connection is uninitialized.
+ LOCAL_UNINIT = Cproton::PN_LOCAL_UNINIT
+ # The local connection is active.
+ LOCAL_ACTIVE = Cproton::PN_LOCAL_ACTIVE
+ # The local connection is closed.
+ LOCAL_CLOSED = Cproton::PN_LOCAL_CLOSED
+
+ # The remote connection is unitialized.
+ REMOTE_UNINIT = Cproton::PN_REMOTE_UNINIT
+ # The remote connection is active.
+ REMOTE_ACTIVE = Cproton::PN_REMOTE_ACTIVE
+ # The remote connection is closed.
+ REMOTE_CLOSED = Cproton::PN_REMOTE_CLOSED
+
+ # Bitmask for the local-only flags.
+ LOCAL_MASK = Cproton::PN_LOCAL_UNINIT |
+ Cproton::PN_LOCAL_ACTIVE |
+ Cproton::PN_LOCAL_CLOSED
+
+ # Bitmask for the remote-only flags.
+ REMOTE_MASK = Cproton::PN_REMOTE_UNINIT |
+ Cproton::PN_REMOTE_ACTIVE |
+ Cproton::PN_REMOTE_CLOSED
+
+ # @private
+ include Util::Engine
+
+ # @private
+ def initialize
+ @condition = nil
+ end
+
+ # @private
+ def _update_condition
+ object_to_condition(@condition, self._local_condition)
+ end
+
+ # @private
+ def remote_condition
+ condition_to_object(self._remote_condition)
+ end
+
+ # Return the transport associated with this endpoint.
+ #
+ # @return [Transport] The transport.
+ #
+ def transport
+ self.connection.transport
+ end
+
+ def local_uninit?
+ check_state(LOCAL_UNINIT)
+ end
+
+ def local_active?
+ check_state(LOCAL_ACTIVE)
+ end
+
+ def local_closed?
+ check_state(LOCAL_CLOSED)
+ end
+
+ def remote_uninit?
+ check_state(REMOTE_UNINIT)
+ end
+
+ def remote_active?
+ check_state(REMOTE_ACTIVE)
+ end
+
+ def remote_closed?
+ check_state(REMOTE_CLOSED)
+ end
+
+ def check_state(state_mask)
+ !(self.state & state_mask).zero?
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0f27065a/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 507b61f..fff9b0b 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -54,6 +54,7 @@ require "event/collector"
# Main Proton classes
require "core/message"
+require "core/endpoint"
# Messenger API classes
require "messenger/filters"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org