Class: Qpid::Proton::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/core/endpoint.rb

Overview

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.

Examples:


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}"

Direct Known Subclasses

Connection, Link, Session

Constant Summary collapse

LOCAL_UNINIT =

The local connection is uninitialized.

Cproton::PN_LOCAL_UNINIT
LOCAL_ACTIVE =

The local connection is active.

Cproton::PN_LOCAL_ACTIVE
LOCAL_CLOSED =

The local connection is closed.

Cproton::PN_LOCAL_CLOSED
REMOTE_UNINIT =

The remote connection is unitialized.

Cproton::PN_REMOTE_UNINIT
REMOTE_ACTIVE =

The remote connection is active.

Cproton::PN_REMOTE_ACTIVE
REMOTE_CLOSED =

The remote connection is closed.

Cproton::PN_REMOTE_CLOSED
LOCAL_MASK =

Bitmask for the local-only flags.

Cproton::PN_LOCAL_UNINIT |
Cproton::PN_LOCAL_ACTIVE |
Cproton::PN_LOCAL_CLOSED
REMOTE_MASK =

Bitmask for the remote-only flags.

Cproton::PN_REMOTE_UNINIT |
Cproton::PN_REMOTE_ACTIVE |
Cproton::PN_REMOTE_CLOSED

Instance Method Summary collapse

Instance Method Details

#check_state(state_mask) ⇒ Object



109
110
111
# File 'lib/core/endpoint.rb', line 109

def check_state(state_mask)
  !(self.state & state_mask).zero?
end

#handlerObject



113
114
115
116
117
118
119
120
121
122
123
# File 'lib/core/endpoint.rb', line 113

def handler
  reactor = Qpid::Proton::Reactor::Reactor.wrap(Cproton.pn_object_reactor(@impl))
  if reactor.nil?
    on_error = nil
  else
    on_error = reactor.method(:on_error)
  end
  record = self.attachments
  puts "record=#{record}"
  WrappedHandler.wrap(Cproton.pn_record_get_handler(record), on_error)
end

#handler=(handler) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/core/endpoint.rb', line 125

def handler=(handler)
  reactor = Qpid::Proton::Reactor::Reactor.wrap(Cproton.pn_object_reactor(@impl))
  if reactor.nil?
    on_error = nil
  else
    on_error = reactor.method(:on_error)
  end
  impl = chandler(handler, on_error)
  record = self.attachments
  Cproton.pn_record_set_handler(record, impl)
  Cproton.pn_decref(impl)
end

#local_active?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/core/endpoint.rb', line 89

def local_active?
  check_state(LOCAL_ACTIVE)
end

#local_closed?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/core/endpoint.rb', line 93

def local_closed?
  check_state(LOCAL_CLOSED)
end

#local_uninit?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/core/endpoint.rb', line 85

def local_uninit?
  check_state(LOCAL_UNINIT)
end

#remote_active?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/core/endpoint.rb', line 101

def remote_active?
  check_state(REMOTE_ACTIVE)
end

#remote_closed?Boolean

Returns:

  • (Boolean)


105
106
107
# File 'lib/core/endpoint.rb', line 105

def remote_closed?
  check_state(REMOTE_CLOSED)
end

#remote_uninit?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/core/endpoint.rb', line 97

def remote_uninit?
  check_state(REMOTE_UNINIT)
end

#transportTransport

Return the transport associated with this endpoint.

Returns:



81
82
83
# File 'lib/core/endpoint.rb', line 81

def transport
  self.connection.transport
end