proton  0
session.h
Go to the documentation of this file.
1 #ifndef PROTON_SESSION_H
2 #define PROTON_SESSION_H 1
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include <proton/import_export.h>
26 #include <proton/type_compat.h>
27 #include <stddef.h>
28 #include <sys/types.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /** @file
35  * Session API for the proton Engine.
36  *
37  * @defgroup session Session
38  * @ingroup engine
39  * @{
40  */
41 
42 /**
43  * Factory for creating a new session on a given connection object.
44  *
45  * Creates a new session object and adds it to the set of sessions
46  * maintained by the connection object.
47  *
48  * @param[in] connection the connection object
49  * @return a pointer to the new session
50  */
52 
53 /**
54  * Free a session object.
55  *
56  * When a session is freed it will no longer be retained by the
57  * connection once any internal references to the session are no
58  * longer needed. Freeing a session will free all links on that
59  * session and settle any deliveries on those links.
60  *
61  * @param[in] session a session object to free (or NULL)
62  */
64 
65 /**
66  * @deprecated
67  * Get the application context that is associated with a session
68  * object.
69  *
70  * The application context for a session may be set using
71  * ::pn_session_set_context.
72  *
73  * @param[in] session the session whose context is to be returned.
74  * @return the application context for the session object
75  */
77 
78 /**
79  * @deprecated
80  * Set a new application context for a session object.
81  *
82  * The application context for a session object may be retrieved
83  * using ::pn_session_get_context.
84  *
85  * @param[in] session the session object
86  * @param[in] context the application context
87  */
88 PN_EXTERN void pn_session_set_context(pn_session_t *session, void *context);
89 
90 /**
91  * Get the attachments that are associated with a session object.
92  *
93  * @param[in] session the session whose attachments are to be returned.
94  * @return the attachments for the session object
95  */
97 
98 /**
99  * Get the endpoint state flags for a session.
100  *
101  * @param[in] session the session
102  * @return the session's state flags
103  */
105 
106 /**
107  * Get additional error information associated with the session.
108  *
109  * Whenever a session operation fails (i.e. returns an error code),
110  * additional error details can be obtained using this function. The
111  * error object that is returned may also be used to clear the error
112  * condition.
113  *
114  * The pointer returned by this operation is valid until the
115  * session object is freed.
116  *
117  * @param[in] session the sesion object
118  * @return the session's error object
119  */
121 
122 /**
123  * Get the local condition associated with the session endpoint.
124  *
125  * The ::pn_condition_t object retrieved may be modified prior to
126  * closing the session in order to indicate a particular condition
127  * exists when the session closes. This is normally used to
128  * communicate error conditions to the remote peer, however it may
129  * also be used in non error cases. See ::pn_condition_t for more
130  * details.
131  *
132  * The pointer returned by this operation is valid until the session
133  * object is freed.
134  *
135  * @param[in] session the session object
136  * @return the session's local condition object
137  */
139 
140 /**
141  * Get the remote condition associated with the session endpoint.
142  *
143  * The ::pn_condition_t object retrieved may be examined in order to
144  * determine whether the remote peer was indicating some sort of
145  * exceptional condition when the remote session endpoint was
146  * closed. The ::pn_condition_t object returned may not be modified.
147  *
148  * The pointer returned by this operation is valid until the
149  * session object is freed.
150  *
151  * @param[in] session the session object
152  * @return the session's remote condition object
153  */
155 
156 /**
157  * Get the parent connection for a session object.
158  *
159  * This operation retrieves the parent pn_connection_t object that
160  * contains the given pn_session_t object.
161  *
162  * @param[in] session the session object
163  * @return the parent connection object
164  */
166 
167 /**
168  * Open a session.
169  *
170  * Once this operation has completed, the PN_LOCAL_ACTIVE state flag
171  * will be set.
172  *
173  * @param[in] session a session object
174  */
175 PN_EXTERN void pn_session_open(pn_session_t *session);
176 
177 /**
178  * Close a session.
179  *
180  * Once this operation has completed, the PN_LOCAL_CLOSED state flag
181  * will be set. This may be called without calling
182  * ::pn_session_open, in this case it is equivalent to calling
183  * ::pn_session_open followed by ::pn_session_close.
184  *
185  * @param[in] session a session object
186  */
188 
189 /**
190  * Get the incoming capacity of the session measured in bytes.
191  *
192  * The incoming capacity of a session determines how much incoming
193  * message data the session will buffer. Note that if this value is
194  * less than the negotiated frame size of the transport, it will be
195  * rounded up to one full frame.
196  *
197  * @param[in] session the session object
198  * @return the incoming capacity of the session in bytes
199  */
201 
202 /**
203  * Set the incoming capacity for a session object.
204  *
205  * The incoming capacity of a session determines how much incoming
206  * message data the session will buffer. Note that if this value is
207  * less than the negotiated frame size of the transport, it will be
208  * rounded up to one full frame.
209  *
210  * @param[in] session the session object
211  * @param[in] capacity the incoming capacity for the session
212  */
213 PN_EXTERN void pn_session_set_incoming_capacity(pn_session_t *session, size_t capacity);
214 
215 /**
216  * Get the number of outgoing bytes currently buffered by a session.
217  *
218  * @param[in] session a session object
219  * @return the number of outgoing bytes currently buffered
220  */
222 
223 /**
224  * Get the number of incoming bytes currently buffered by a session.
225  *
226  * @param[in] session a session object
227  * @return the number of incoming bytes currently buffered
228  */
230 
231 /**
232  * Retrieve the first session from a given connection that matches the
233  * specified state mask.
234  *
235  * Examines the state of each session owned by the connection, and
236  * returns the first session that matches the given state mask. If
237  * state contains both local and remote flags, then an exact match
238  * against those flags is performed. If state contains only local or
239  * only remote flags, then a match occurs if any of the local or
240  * remote flags are set respectively.
241  *
242  * @param[in] connection to be searched for matching sessions
243  * @param[in] state mask to match
244  * @return the first session owned by the connection that matches the
245  * mask, else NULL if no sessions match
246  */
248 
249 /**
250  * Retrieve the next session from a given connection that matches the
251  * specified state mask.
252  *
253  * When used with ::pn_session_head, application can access all
254  * sessions on the connection that match the given state. See
255  * ::pn_session_head for description of match behavior.
256  *
257  * @param[in] session the previous session obtained from
258  * ::pn_session_head or ::pn_session_next
259  * @param[in] state mask to match.
260  * @return the next session owned by the connection that matches the
261  * mask, else NULL if no sessions match
262  */
264 
265 /** @}
266  */
267 
268 #ifdef __cplusplus
269 }
270 #endif
271 
272 #endif /* session.h */
PN_EXTERN void pn_session_set_context(pn_session_t *session, void *context)
PN_EXTERN void pn_session_open(pn_session_t *session)
Open a session.
PN_EXTERN void * pn_session_get_context(pn_session_t *session)
struct pn_error_t pn_error_t
Definition: error.h:32
struct pn_record_t pn_record_t
Definition: object.h:46
struct pn_connection_t pn_connection_t
An AMQP Connection object.
Definition: types.h:112
PN_EXTERN void pn_session_close(pn_session_t *session)
Close a session.
PN_EXTERN void pn_session_free(pn_session_t *session)
Free a session object.
PN_EXTERN pn_connection_t * pn_session_connection(pn_session_t *session)
Get the parent connection for a session object.
#define PN_EXTERN
Definition: import_export.h:53
PN_EXTERN pn_condition_t * pn_session_remote_condition(pn_session_t *session)
Get the remote condition associated with the session endpoint.
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...
PN_EXTERN pn_session_t * pn_session(pn_connection_t *connection)
Factory for creating a new session on a given connection object.
PN_EXTERN pn_error_t * pn_session_error(pn_session_t *session)
Get additional error information associated with the session.
PN_EXTERN void pn_session_set_incoming_capacity(pn_session_t *session, size_t capacity)
Set the incoming capacity for a session object.
PN_EXTERN pn_record_t * pn_session_attachments(pn_session_t *session)
Get the attachments that are associated with a session object.
PN_EXTERN size_t pn_session_incoming_bytes(pn_session_t *session)
Get the number of incoming bytes currently buffered by a session.
PN_EXTERN pn_state_t pn_session_state(pn_session_t *session)
Get the endpoint state flags for a session.
struct pn_session_t pn_session_t
An AMQP Session object.
Definition: types.h:123
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...
struct pn_condition_t pn_condition_t
An AMQP Condition object.
Definition: condition.h:65
int pn_state_t
Holds the state flags for an AMQP endpoint.
Definition: types.h:97
PN_EXTERN size_t pn_session_get_incoming_capacity(pn_session_t *session)
Get the incoming capacity of the session measured in bytes.
PN_EXTERN size_t pn_session_outgoing_bytes(pn_session_t *session)
Get the number of outgoing bytes currently buffered by a session.
PN_EXTERN pn_condition_t * pn_session_condition(pn_session_t *session)
Get the local condition associated with the session endpoint.