Session
Engine

## Typedefs

typedef struct pn_session_t | pn_session_t
| An AMQP Session object. More...

## Functions

PN_EXTERN pn_session_t * | pn_session (pn_connection_t *connection)
| Factory for creating a new session on a given connection object. More...
PN_EXTERN void | pn_session_free (pn_session_t *session)
| Free a session object. More...
PN_EXTERN void * | pn_session_get_context (pn_session_t *session)
PN_EXTERN void | pn_session_set_context (pn_session_t *session, void *context)
PN_EXTERN pn_record_t * | pn_session_attachments (pn_session_t *session)
| Get the attachments that are associated with a session object. More...
PN_EXTERN pn_state_t | pn_session_state (pn_session_t *session)
| Get the endpoint state flags for a session. More...
PN_EXTERN pn_error_t * | pn_session_error (pn_session_t *session)
| Get additional error information associated with the session. More...
PN_EXTERN pn_condition_t * | pn_session_condition (pn_session_t *session)
| Get the local condition associated with the session endpoint. More...
PN_EXTERN pn_condition_t * | pn_session_remote_condition (pn_session_t *session)
| Get the remote condition associated with the session endpoint. More...
PN_EXTERN pn_connection_t * | pn_session_connection (pn_session_t *session)
| Get the parent connection for a session object. More...
PN_EXTERN void | pn_session_open (pn_session_t *session)
| Open a session. More...
PN_EXTERN void | pn_session_close (pn_session_t *session)
| Close a session. More...
PN_EXTERN size_t | pn_session_get_incoming_capacity (pn_session_t *session)
| Get the incoming capacity of the session measured in bytes. More...
PN_EXTERN void | pn_session_set_incoming_capacity (pn_session_t *session, size_t capacity)
| Set the incoming capacity for a session object. More...
PN_EXTERN size_t | pn_session_get_outgoing_window (pn_session_t *session)
| Get the outgoing window for a session object. More...
PN_EXTERN void | pn_session_set_outgoing_window (pn_session_t *session, size_t window)
| Set the outgoing window for a session object. More...
PN_EXTERN size_t | pn_session_outgoing_bytes (pn_session_t *session)
| Get the number of outgoing bytes currently buffered by a session. More...
PN_EXTERN size_t | pn_session_incoming_bytes (pn_session_t *session)
| Get the number of incoming bytes currently buffered by a session. More...
PN_EXTERN pn_session_t * | pn_session_head (pn_connection_t *connection, pn_state_t state)
| Retrieve the first session from a given connection that matches the specified state mask. More...
PN_EXTERN pn_session_t * | pn_session_next (pn_session_t *session, pn_state_t state)
| Retrieve the next session from a given connection that matches the specified state mask. More...

## Detailed Description

## Typedef Documentation

## pn_session_t

typedef struct pn_session_t pn_session_t

An AMQP Session object.

A pn_session_t object encapsulates all of the endpoint state associated with an AMQP Session. A pn_session_t object contains zero or more pn_link_t objects.

## Function Documentation

## pn_session()

PN_EXTERN pn_session_t* pn_session | ( | pn_connection_t * | connection | ) |

Factory for creating a new session on a given connection object.

Creates a new session object and adds it to the set of sessions maintained by the connection object.

Parameters

  [in] | connection | the connection object

Returns
  a pointer to the new session

## pn_session_attachments()

PN_EXTERN pn_record_t* pn_session_attachments | ( | pn_session_t * | session | ) |

Get the attachments that are associated with a session object.

Parameters

  [in] | session | the session whose attachments are to be returned.

Returns
  the attachments for the session object

## pn_session_close()

PN_EXTERN void pn_session_close | ( | pn_session_t * | session | ) |

Close a session.

Once this operation has completed, the PN_LOCAL_CLOSED state flag will be set. This may be called without calling pn_session_open, in this case it is equivalent to calling pn_session_open followed by pn_session_close.

Parameters

  [in] | session | a session object

## pn_session_condition()

PN_EXTERN pn_condition_t* pn_session_condition | ( | pn_session_t * | session | ) |

Get the local condition associated with the session endpoint.

The pn_condition_t object retrieved may be modified prior to closing the session in order to indicate a particular condition exists when the session closes. This is normally used to communicate error conditions to the remote peer, however it may also be used in non error cases. See pn_condition_t for more details.

The pointer returned by this operation is valid until the session object is freed.

Parameters

  [in] | session | the session object

Returns
  the session's local condition object

## pn_session_connection()

PN_EXTERN pn_connection_t* pn_session_connection | ( | pn_session_t * | session | ) |

Get the parent connection for a session object.

This operation retrieves the parent pn_connection_t object that contains the given pn_session_t object.

Parameters

  [in] | session | the session object

Returns
  the parent connection object

## pn_session_error()

PN_EXTERN pn_error_t* pn_session_error | ( | pn_session_t * | session | ) |

Get additional error information associated with the session.

Whenever a session operation fails (i.e. returns an error code), additional error details can be obtained using this function. The error object that is returned may also be used to clear the error condition.

The pointer returned by this operation is valid until the session object is freed.

Parameters

  [in] | session | the sesion object

Returns
  the session's error object

## pn_session_free()

PN_EXTERN void pn_session_free | ( | pn_session_t * | session | ) |

Free a session object.

When a session is freed it will no longer be retained by the connection once any internal references to the session are no longer needed. Freeing a session will free all links on that session and settle any deliveries on those links.

Parameters

  [in] | session | a session object to free (or NULL)

## pn_session_get_context()

PN_EXTERN void* pn_session_get_context | ( | pn_session_t * | session | ) |

Deprecated:
  Get the application context that is associated with a session object.

The application context for a session may be set using pn_session_set_context.

Parameters

  [in] | session | the session whose context is to be returned.

Returns
  the application context for the session object

## pn_session_get_incoming_capacity()

PN_EXTERN size_t pn_session_get_incoming_capacity | ( | pn_session_t * | session | ) |

Get the incoming capacity of the session measured in bytes.

The incoming capacity of a session determines how much incoming message data the session will buffer. Note that if this value is less than the negotiated frame size of the transport, it will be rounded up to one full frame.

Parameters

  [in] | session | the session object

Returns
  the incoming capacity of the session in bytes

## pn_session_get_outgoing_window()

PN_EXTERN size_t pn_session_get_outgoing_window | ( | pn_session_t * | session | ) |

Get the outgoing window for a session object.

Parameters

  [in] | session | the session object

Returns
  the outgoing window for the session

## pn_session_head()

PN_EXTERN pn_session_t* pn_session_head | ( | pn_connection_t * | connection,
|  | pn_state_t | state
| ) |  |

Retrieve the first session from a given connection that matches the specified state mask.

Examines the state of each session owned by the connection, and returns the first session that matches the given state mask. If state contains both local and remote flags, then an exact match against those flags is performed. If state contains only local or only remote flags, then a match occurs if any of the local or remote flags are set respectively.

Parameters

  [in] | connection | to be searched for matching sessions
  [in] | state | mask to match

Returns
  the first session owned by the connection that matches the mask, else NULL if no sessions match

## pn_session_incoming_bytes()

PN_EXTERN size_t pn_session_incoming_bytes | ( | pn_session_t * | session | ) |

Get the number of incoming bytes currently buffered by a session.

Parameters

  [in] | session | a session object

Returns
  the number of incoming bytes currently buffered

## pn_session_next()

PN_EXTERN pn_session_t* pn_session_next | ( | pn_session_t * | session,
|  | pn_state_t | state
| ) |  |

Retrieve the next session from a given connection that matches the specified state mask.

When used with pn_session_head, application can access all sessions on the connection that match the given state. See pn_session_head for description of match behavior.

Parameters

  [in] | session | the previous session obtained from pn_session_head or pn_session_next
  [in] | state | mask to match.

Returns
  the next session owned by the connection that matches the mask, else NULL if no sessions match

## pn_session_open()

PN_EXTERN void pn_session_open | ( | pn_session_t * | session | ) |

Open a session.

Once this operation has completed, the PN_LOCAL_ACTIVE state flag will be set.

Parameters

  [in] | session | a session object

## pn_session_outgoing_bytes()

PN_EXTERN size_t pn_session_outgoing_bytes | ( | pn_session_t * | session | ) |

Get the number of outgoing bytes currently buffered by a session.

Parameters

  [in] | session | a session object

Returns
  the number of outgoing bytes currently buffered

## pn_session_remote_condition()

PN_EXTERN pn_condition_t* pn_session_remote_condition | ( | pn_session_t * | session | ) |

Get the remote condition associated with the session endpoint.

The pn_condition_t object retrieved may be examined in order to determine whether the remote peer was indicating some sort of exceptional condition when the remote session endpoint was closed. The pn_condition_t object returned may not be modified.

The pointer returned by this operation is valid until the session object is freed.

Parameters

  [in] | session | the session object

Returns
  the session's remote condition object

## pn_session_set_context()

PN_EXTERN void pn_session_set_context | ( | pn_session_t * | session,
|  | void * | context
| ) |  |

Deprecated:
  Set a new application context for a session object.

The application context for a session object may be retrieved using pn_session_get_context.

Parameters

  [in] | session | the session object
  [in] | context | the application context

## pn_session_set_incoming_capacity()

PN_EXTERN void pn_session_set_incoming_capacity | ( | pn_session_t * | session,
|  | size_t | capacity
| ) |  |

Set the incoming capacity for a session object.

The incoming capacity of a session determines how much incoming message data the session will buffer. Note that if this value is less than the negotiated frame size of the transport, it will be rounded up to one full frame.

Parameters

  [in] | session | the session object
  [in] | capacity | the incoming capacity for the session

## pn_session_set_outgoing_window()

PN_EXTERN void pn_session_set_outgoing_window | ( | pn_session_t * | session,
|  | size_t | window
| ) |  |

Set the outgoing window for a session object.

Parameters

  [in] | session | the session object
  [in] | window | the outgoing window for the session

## pn_session_state()

PN_EXTERN pn_state_t pn_session_state | ( | pn_session_t * | session | ) |

Get the endpoint state flags for a session.

Parameters

  [in] | session | the session

Returns
  the session's state flags