Class: Qpid::Proton::Session

Inherits:
Endpoint show all
Defined in:
lib/core/session.rb

Overview

A session is the parent for senders and receivers.

A Session has a single parent Qpid::Proton::Connection instance.

Constant Summary

Constants inherited from Endpoint

Endpoint::LOCAL_ACTIVE, Endpoint::LOCAL_CLOSED, Endpoint::LOCAL_MASK, Endpoint::LOCAL_UNINIT, Endpoint::REMOTE_ACTIVE, Endpoint::REMOTE_CLOSED, Endpoint::REMOTE_MASK, Endpoint::REMOTE_UNINIT

Instance Method Summary collapse

Methods inherited from Endpoint

#closed?, #local_closed?, #local_open?, #local_uninit?, #open?, #remote_closed?, #remote_open?, #remote_uninit?, #transport, #work_queue

Instance Method Details

#close(error = nil)

Close the local end of the session. The remote end may or may not be closed.

Parameters:

  • error (Condition) (defaults to: nil)

    Optional error condition to send with the close.



82
83
84
85
# File 'lib/core/session.rb', line 82

def close(error=nil)
  Condition.assign(_local_condition, error)
  Cproton.pn_session_close(@impl)
end

#connectionConnection

Returns the parent connection.

Returns:



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

def connection
  Connection.wrap(Cproton.pn_session_connection(@impl))
end

Get the links on this Session.

Overloads:

  • #each_link {|l| ... }

    Yield Parameters:

    • l (Link)

      pass each link to block

  • #each_linkEnumerator

    Returns enumerator over links.

    Returns:

    • (Enumerator)

      enumerator over links



132
133
134
135
136
137
138
139
140
141
# File 'lib/core/session.rb', line 132

def each_link
  return enum_for(:each_link) unless block_given?
  l = Cproton.pn_link_head(Cproton.pn_session_connection(@impl), 0);
  while l
    link = Link.wrap(l)
    yield link if link.session == self
    l = Cproton.pn_link_next(l, 0)
  end
  self
end

#each_receiver

Get the Receiver links - see #each_link



147
# File 'lib/core/session.rb', line 147

def each_receiver() each_link.select { |l| l.receiver? }; end

#each_sender

Get the Qpid::Proton::Sender links - see #each_link



144
# File 'lib/core/session.rb', line 144

def each_sender() each_link.select { |l| l.sender? }; end

#next(state_mask)

Deprecated.


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

def next(state_mask)
  deprecated __method__, "Connection#each_session"
  Session.wrap(Cproton.pn_session_next(@impl, state_mask))
end

#open_receiver(opts = nil) ⇒ Receiver

Create and open a Receiver link, see Receiver#open

Parameters:

  • opts (Hash) (defaults to: nil)

    receiver options, see Receiver#open

Returns:



116
117
118
# File 'lib/core/session.rb', line 116

def open_receiver(opts=nil) 
  Receiver.new(Cproton.pn_receiver(@impl, link_name(opts))).open(opts)
end

#open_sender(opts = nil) ⇒ Sender

Create and open a Qpid::Proton::Sender link, see #open

Parameters:

Returns:



123
124
125
# File 'lib/core/session.rb', line 123

def open_sender(opts=nil)
  Sender.new(Cproton.pn_sender(@impl, link_name(opts))).open(opts)
end

#receiver(name)

Deprecated.


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

def receiver(name)
  deprecated __method__, "open_receiver"
  Receiver.new(Cproton.pn_receiver(@impl, name))
end

#sender(name)

Deprecated.


102
103
104
105
# File 'lib/core/session.rb', line 102

def sender(name)
  deprecated __method__, "open_sender"
  Sender.new(Cproton.pn_sender(@impl, name));
end