| 1 |
#ifndef PROTON_EVENT_H |
| 2 |
#define PROTON_EVENT_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 <proton/object.h> |
| 28 |
#include <stddef.h> |
| 29 |
|
| 30 |
#ifdef __cplusplus |
| 31 |
extern "C" { |
| 32 |
#endif |
| 33 |
|
| 34 |
/** |
| 35 |
* @file |
| 36 |
* |
| 37 |
* @copybrief event |
| 38 |
* |
| 39 |
* @addtogroup event |
| 40 |
* @{ |
| 41 |
*/ |
| 42 |
|
| 43 |
/** |
| 44 |
* Notification of a state change in the protocol engine. |
| 45 |
* |
| 46 |
* The AMQP endpoint state modeled by the protocol engine is captured |
| 47 |
* by the following object types: @link pn_delivery_t Deliveries |
| 48 |
* @endlink, @link pn_link_t Links @endlink, @link pn_session_t |
| 49 |
* Sessions @endlink, @link pn_connection_t Connections @endlink, and |
| 50 |
* @link pn_transport_t Transports @endlink. These objects are related |
| 51 |
* as follows: |
| 52 |
* |
| 53 |
* - @link pn_delivery_t Deliveries @endlink always have a single |
| 54 |
* parent Link |
| 55 |
* - @link pn_link_t Links @endlink always have a single parent |
| 56 |
* Session |
| 57 |
* - @link pn_session_t Sessions @endlink always have a single parent |
| 58 |
* Connection |
| 59 |
* - @link pn_connection_t Connections @endlink optionally have at |
| 60 |
* most one associated Transport |
| 61 |
* - @link pn_transport_t Transports @endlink optionally have at most |
| 62 |
* one associated Connection |
| 63 |
* |
| 64 |
* Every event has a type (see ::pn_event_type_t) that identifies what |
| 65 |
* sort of state change has occurred along with a pointer to the |
| 66 |
* object whose state has changed (as well as its associated objects). |
| 67 |
* |
| 68 |
* Events are accessed by creating a @link pn_collector_t Collector |
| 69 |
* @endlink with ::pn_collector() and registering it with the @link |
| 70 |
* pn_connection_t Connection @endlink of interest through use of |
| 71 |
* ::pn_connection_collect(). Once a collector has been registered, |
| 72 |
* ::pn_collector_peek() and ::pn_collector_pop() are used to access |
| 73 |
* and process events. |
| 74 |
*/ |
| 75 |
typedef struct pn_event_t pn_event_t; |
| 76 |
|
| 77 |
/** |
| 78 |
* An event type. |
| 79 |
*/ |
| 80 |
typedef enum { |
| 81 |
/** |
| 82 |
* Defined as a programming convenience. No event of this type will |
| 83 |
* ever be generated. |
| 84 |
*/ |
| 85 |
PN_EVENT_NONE = 0, |
| 86 |
|
| 87 |
/** |
| 88 |
* A reactor has been started. Events of this type point to the reactor. |
| 89 |
*/ |
| 90 |
PN_REACTOR_INIT, |
| 91 |
|
| 92 |
/** |
| 93 |
* A reactor has no more events to process. Events of this type |
| 94 |
* point to the reactor. |
| 95 |
*/ |
| 96 |
PN_REACTOR_QUIESCED, |
| 97 |
|
| 98 |
/** |
| 99 |
* A reactor has been stopped. Events of this type point to the reactor. |
| 100 |
*/ |
| 101 |
PN_REACTOR_FINAL, |
| 102 |
|
| 103 |
/** |
| 104 |
* A timer event has occurred. |
| 105 |
*/ |
| 106 |
PN_TIMER_TASK, |
| 107 |
|
| 108 |
/** |
| 109 |
* The connection has been created. This is the first event that |
| 110 |
* will ever be issued for a connection. Events of this type point |
| 111 |
* to the relevant connection. |
| 112 |
*/ |
| 113 |
PN_CONNECTION_INIT, |
| 114 |
|
| 115 |
/** |
| 116 |
* The connection has been bound to a transport. This event is |
| 117 |
* issued when the ::pn_transport_bind() operation is invoked. |
| 118 |
*/ |
| 119 |
PN_CONNECTION_BOUND, |
| 120 |
|
| 121 |
/** |
| 122 |
* The connection has been unbound from its transport. This event is |
| 123 |
* issued when the ::pn_transport_unbind() operation is invoked. |
| 124 |
*/ |
| 125 |
PN_CONNECTION_UNBOUND, |
| 126 |
|
| 127 |
/** |
| 128 |
* The local connection endpoint has been closed. Events of this |
| 129 |
* type point to the relevant connection. |
| 130 |
*/ |
| 131 |
PN_CONNECTION_LOCAL_OPEN, |
| 132 |
|
| 133 |
/** |
| 134 |
* The remote endpoint has opened the connection. Events of this |
| 135 |
* type point to the relevant connection. |
| 136 |
*/ |
| 137 |
PN_CONNECTION_REMOTE_OPEN, |
| 138 |
|
| 139 |
/** |
| 140 |
* The local connection endpoint has been closed. Events of this |
| 141 |
* type point to the relevant connection. |
| 142 |
*/ |
| 143 |
PN_CONNECTION_LOCAL_CLOSE, |
| 144 |
|
| 145 |
/** |
| 146 |
* The remote endpoint has closed the connection. Events of this |
| 147 |
* type point to the relevant connection. |
| 148 |
*/ |
| 149 |
PN_CONNECTION_REMOTE_CLOSE, |
| 150 |
|
| 151 |
/** |
| 152 |
* The connection has been freed and any outstanding processing has |
| 153 |
* been completed. This is the final event that will ever be issued |
| 154 |
* for a connection. |
| 155 |
*/ |
| 156 |
PN_CONNECTION_FINAL, |
| 157 |
|
| 158 |
/** |
| 159 |
* The session has been created. This is the first event that will |
| 160 |
* ever be issued for a session. |
| 161 |
*/ |
| 162 |
PN_SESSION_INIT, |
| 163 |
|
| 164 |
/** |
| 165 |
* The local session endpoint has been opened. Events of this type |
| 166 |
* point to the relevant session. |
| 167 |
*/ |
| 168 |
PN_SESSION_LOCAL_OPEN, |
| 169 |
|
| 170 |
/** |
| 171 |
* The remote endpoint has opened the session. Events of this type |
| 172 |
* point to the relevant session. |
| 173 |
*/ |
| 174 |
PN_SESSION_REMOTE_OPEN, |
| 175 |
|
| 176 |
/** |
| 177 |
* The local session endpoint has been closed. Events of this type |
| 178 |
* point ot the relevant session. |
| 179 |
*/ |
| 180 |
PN_SESSION_LOCAL_CLOSE, |
| 181 |
|
| 182 |
/** |
| 183 |
* The remote endpoint has closed the session. Events of this type |
| 184 |
* point to the relevant session. |
| 185 |
*/ |
| 186 |
PN_SESSION_REMOTE_CLOSE, |
| 187 |
|
| 188 |
/** |
| 189 |
* The session has been freed and any outstanding processing has |
| 190 |
* been completed. This is the final event that will ever be issued |
| 191 |
* for a session. |
| 192 |
*/ |
| 193 |
PN_SESSION_FINAL, |
| 194 |
|
| 195 |
/** |
| 196 |
* The link has been created. This is the first event that will ever |
| 197 |
* be issued for a link. |
| 198 |
*/ |
| 199 |
PN_LINK_INIT, |
| 200 |
|
| 201 |
/** |
| 202 |
* The local link endpoint has been opened. Events of this type |
| 203 |
* point ot the relevant link. |
| 204 |
*/ |
| 205 |
PN_LINK_LOCAL_OPEN, |
| 206 |
|
| 207 |
/** |
| 208 |
* The remote endpoint has opened the link. Events of this type |
| 209 |
* point to the relevant link. |
| 210 |
*/ |
| 211 |
PN_LINK_REMOTE_OPEN, |
| 212 |
|
| 213 |
/** |
| 214 |
* The local link endpoint has been closed. Events of this type |
| 215 |
* point to the relevant link. |
| 216 |
*/ |
| 217 |
PN_LINK_LOCAL_CLOSE, |
| 218 |
|
| 219 |
/** |
| 220 |
* The remote endpoint has closed the link. Events of this type |
| 221 |
* point to the relevant link. |
| 222 |
*/ |
| 223 |
PN_LINK_REMOTE_CLOSE, |
| 224 |
|
| 225 |
/** |
| 226 |
* The local link endpoint has been detached. Events of this type |
| 227 |
* point to the relevant link. |
| 228 |
*/ |
| 229 |
PN_LINK_LOCAL_DETACH, |
| 230 |
|
| 231 |
/** |
| 232 |
* The remote endpoint has detached the link. Events of this type |
| 233 |
* point to the relevant link. |
| 234 |
*/ |
| 235 |
PN_LINK_REMOTE_DETACH, |
| 236 |
|
| 237 |
/** |
| 238 |
* The flow control state for a link has changed. Events of this |
| 239 |
* type point to the relevant link. |
| 240 |
*/ |
| 241 |
PN_LINK_FLOW, |
| 242 |
|
| 243 |
/** |
| 244 |
* The link has been freed and any outstanding processing has been |
| 245 |
* completed. This is the final event that will ever be issued for a |
| 246 |
* link. Events of this type point to the relevant link. |
| 247 |
*/ |
| 248 |
PN_LINK_FINAL, |
| 249 |
|
| 250 |
/** |
| 251 |
* A delivery has been created or updated. Events of this type point |
| 252 |
* to the relevant delivery. |
| 253 |
*/ |
| 254 |
PN_DELIVERY, |
| 255 |
|
| 256 |
/** |
| 257 |
* The transport has new data to read and/or write. Events of this |
| 258 |
* type point to the relevant transport. |
| 259 |
*/ |
| 260 |
PN_TRANSPORT, |
| 261 |
|
| 262 |
/** |
| 263 |
* The transport has authenticated. If this is received by a server |
| 264 |
* the associated transport has authenticated an incoming connection |
| 265 |
* and pn_transport_get_user() can be used to obtain the authenticated |
| 266 |
* user. |
| 267 |
*/ |
| 268 |
PN_TRANSPORT_AUTHENTICATED, |
| 269 |
|
| 270 |
/** |
| 271 |
* Indicates that a transport error has occurred. Use |
| 272 |
* ::pn_transport_condition() to access the details of the error |
| 273 |
* from the associated transport. |
| 274 |
*/ |
| 275 |
PN_TRANSPORT_ERROR, |
| 276 |
|
| 277 |
/** |
| 278 |
* Indicates that the "head" or writing end of the transport has been closed. This |
| 279 |
* means the transport will never produce more bytes for output to |
| 280 |
* the network. Events of this type point to the relevant transport. |
| 281 |
*/ |
| 282 |
PN_TRANSPORT_HEAD_CLOSED, |
| 283 |
|
| 284 |
/** |
| 285 |
* Indicates that the tail of the transport has been closed. This |
| 286 |
* means the transport will never be able to process more bytes from |
| 287 |
* the network. Events of this type point to the relevant transport. |
| 288 |
*/ |
| 289 |
PN_TRANSPORT_TAIL_CLOSED, |
| 290 |
|
| 291 |
/** |
| 292 |
* Indicates that the both the head and tail of the transport are |
| 293 |
* closed. Events of this type point to the relevant transport. |
| 294 |
*/ |
| 295 |
PN_TRANSPORT_CLOSED, |
| 296 |
|
| 297 |
PN_SELECTABLE_INIT, |
| 298 |
PN_SELECTABLE_UPDATED, |
| 299 |
PN_SELECTABLE_READABLE, |
| 300 |
PN_SELECTABLE_WRITABLE, |
| 301 |
PN_SELECTABLE_ERROR, |
| 302 |
PN_SELECTABLE_EXPIRED, |
| 303 |
PN_SELECTABLE_FINAL, |
| 304 |
|
| 305 |
/** |
| 306 |
* pn_connection_wake() was called. |
| 307 |
* Events of this type point to the @ref pn_connection_t. |
| 308 |
*/ |
| 309 |
PN_CONNECTION_WAKE, |
| 310 |
|
| 311 |
/** |
| 312 |
* Indicates the listener has an incoming connection, call pn_listener_accept2() |
| 313 |
* to accept it. |
| 314 |
* Events of this type point to the @ref pn_listener_t. |
| 315 |
*/ |
| 316 |
PN_LISTENER_ACCEPT, |
| 317 |
|
| 318 |
/** |
| 319 |
* Indicates the listener has closed. pn_listener_condition() provides error information. |
| 320 |
* Events of this type point to the @ref pn_listener_t. |
| 321 |
*/ |
| 322 |
PN_LISTENER_CLOSE, |
| 323 |
|
| 324 |
/** |
| 325 |
* Indicates pn_proactor_interrupt() was called to interrupt a proactor thread. |
| 326 |
* Events of this type point to the @ref pn_proactor_t. |
| 327 |
*/ |
| 328 |
PN_PROACTOR_INTERRUPT, |
| 329 |
|
| 330 |
/** |
| 331 |
* Timeout set by pn_proactor_set_timeout() time limit expired. |
| 332 |
* Events of this type point to the @ref pn_proactor_t. |
| 333 |
*/ |
| 334 |
PN_PROACTOR_TIMEOUT, |
| 335 |
|
| 336 |
/** |
| 337 |
* The proactor has become inactive: all listeners and connections were closed |
| 338 |
* and the timeout (if set) expired or was cancelled. There will be no |
| 339 |
* further events unless new listeners or connections are opened, or a new |
| 340 |
* timeout is set (possibly in other threads in a multi-threaded program.) |
| 341 |
* |
| 342 |
* Events of this type point to the @ref pn_proactor_t. |
| 343 |
*/ |
| 344 |
PN_PROACTOR_INACTIVE, |
| 345 |
|
| 346 |
/** |
| 347 |
* The listener is listening. |
| 348 |
* Events of this type point to the @ref pn_listener_t. |
| 349 |
*/ |
| 350 |
PN_LISTENER_OPEN, |
| 351 |
|
| 352 |
/** |
| 353 |
* The raw connection connected. |
| 354 |
* Now would be a good time to give the raw connection some buffers |
| 355 |
* to read bytes from the underlying socket. If you don't do it |
| 356 |
* now you will get @ref PN_RAW_CONNECTION_NEED_READ_BUFFERS (and |
| 357 |
* @ref PN_RAW_CONNECTION_NEED_WRITE_BUFFERS) events when the socket is readable |
| 358 |
* (or writable) but there are not buffers available. |
| 359 |
* |
| 360 |
* Events of this type point to a @ref pn_raw_connection_t |
| 361 |
*/ |
| 362 |
PN_RAW_CONNECTION_CONNECTED, |
| 363 |
|
| 364 |
/** |
| 365 |
* The remote end of the raw connection closed the connection so |
| 366 |
* that we can no longer read. |
| 367 |
* |
| 368 |
* When both this and @ref PN_RAW_CONNECTION_CLOSED_WRITE event have |
| 369 |
* occurred then the @ref PN_RAW_CONNECTION_DISCONNECTED event will be |
| 370 |
* generated. |
| 371 |
* |
| 372 |
* Events of this type point to a @ref pn_raw_connection_t |
| 373 |
*/ |
| 374 |
PN_RAW_CONNECTION_CLOSED_READ, |
| 375 |
|
| 376 |
/** |
| 377 |
* The remote end of the raw connection closed the connection so |
| 378 |
* that we can no longer write. |
| 379 |
* |
| 380 |
* When both this and @ref PN_RAW_CONNECTION_CLOSED_READ event have |
| 381 |
* occurred then the @ref PN_RAW_CONNECTION_DISCONNECTED event will be |
| 382 |
* generated. |
| 383 |
* |
| 384 |
* Events of this type point to a @ref pn_raw_connection_t |
| 385 |
*/ |
| 386 |
PN_RAW_CONNECTION_CLOSED_WRITE, |
| 387 |
|
| 388 |
/** |
| 389 |
* The raw connection is disconnected. |
| 390 |
* No more bytes will be read or written on the connection. Every buffer |
| 391 |
* in use will already either have been returned using a |
| 392 |
* @ref PN_RAW_CONNECTION_READ or @ref PN_RAW_CONNECTION_WRITTEN event. |
| 393 |
* This event will always be the last for this raw connection, and so |
| 394 |
* the application can clean up the raw connection at this point. |
| 395 |
* |
| 396 |
* Events of this type point to a @ref pn_raw_connection_t |
| 397 |
*/ |
| 398 |
PN_RAW_CONNECTION_DISCONNECTED, |
| 399 |
|
| 400 |
/** |
| 401 |
* The raw connection might need more read buffers. |
| 402 |
* The connection is readable, but the connection has no buffer to read the |
| 403 |
* bytes into. If you supply some buffers now maybe you'll get a |
| 404 |
* @ref PN_RAW_CONNECTION_READ event soon, but no guarantees. |
| 405 |
* |
| 406 |
* This event is edge triggered and you will only get it once until you give |
| 407 |
* the raw connection some more read buffers. |
| 408 |
* |
| 409 |
* Events of this type point to a @ref pn_raw_connection_t |
| 410 |
*/ |
| 411 |
PN_RAW_CONNECTION_NEED_READ_BUFFERS, |
| 412 |
|
| 413 |
/** |
| 414 |
* The raw connection might need more write buffers. |
| 415 |
* The connection is writable but has no buffers to write. If you give the |
| 416 |
* raw connection something to write using @ref pn_raw_connection_write_buffers |
| 417 |
* the raw connection can write them. It is not necessary to wait for this event |
| 418 |
* before sending buffers to write, but it can be used to aid in flow control (maybe). |
| 419 |
* |
| 420 |
* This event is edge triggered and you will only get it once until you give |
| 421 |
* the raw connection something more to write. |
| 422 |
* |
| 423 |
* Events of this type point to a @ref pn_raw_connection_t |
| 424 |
*/ |
| 425 |
PN_RAW_CONNECTION_NEED_WRITE_BUFFERS, |
| 426 |
|
| 427 |
/** |
| 428 |
* The raw connection read bytes: The bytes that were read are |
| 429 |
* in one of the read buffers given to the raw connection. |
| 430 |
* |
| 431 |
* This event will be sent if there are bytes that have been read |
| 432 |
* in a buffer owned by the raw connection and there is no |
| 433 |
* @ref PN_RAW_CONNECTION_READ event still queued. |
| 434 |
* |
| 435 |
* When a connection closes all read buffers are returned to the |
| 436 |
* application using @ref PN_RAW_CONNECTION_READ events with empty buffers. |
| 437 |
* |
| 438 |
* Events of this type point to a @ref pn_raw_connection_t |
| 439 |
*/ |
| 440 |
PN_RAW_CONNECTION_READ, |
| 441 |
|
| 442 |
/** |
| 443 |
* The raw connection has finished a write and the buffers that were |
| 444 |
* used are no longer in use and can be recycled. |
| 445 |
* |
| 446 |
* This event will be sent if there are buffers that have been written still |
| 447 |
* owned by the raw connection and there is no @ref PN_RAW_CONNECTION_WRITTEN |
| 448 |
* event currently queued. |
| 449 |
* |
| 450 |
* When a connection closes all write buffers are returned using |
| 451 |
* @ref PN_RAW_CONNECTION_WRITTEN events. |
| 452 |
* |
| 453 |
* Events of this type point to a @ref pn_raw_connection_t |
| 454 |
*/ |
| 455 |
PN_RAW_CONNECTION_WRITTEN, |
| 456 |
|
| 457 |
/** |
| 458 |
* The raw connection was woken by @ref pn_raw_connection_wake |
| 459 |
* |
| 460 |
* Events of this type point to a @ref pn_raw_connection_t |
| 461 |
*/ |
| 462 |
PN_RAW_CONNECTION_WAKE, |
| 463 |
|
| 464 |
/** |
| 465 |
* The raw connection is returning all the remaining buffers to the application. |
| 466 |
* |
| 467 |
* The raw connection is about to disconnect and shutdown. To avoid leaking the buffers |
| 468 |
* the application must take the buffers back used @ref pn_raw_connection_take_read_buffers |
| 469 |
* and @ref pn_raw_connection_take_write_buffers. |
| 470 |
* |
| 471 |
* Events of this type point to a @ref pn_raw_connection_t |
| 472 |
*/ |
| 473 |
PN_RAW_CONNECTION_DRAIN_BUFFERS |
| 474 |
|
| 475 |
} pn_event_type_t; |
| 476 |
|
| 477 |
|
| 478 |
/** |
| 479 |
* Get a human readable name for an event type. |
| 480 |
* |
| 481 |
* @param[in] type an event type |
| 482 |
* @return a human readable name |
| 483 |
*/ |
| 484 |
PN_EXTERN const char *pn_event_type_name(pn_event_type_t type); |
| 485 |
|
| 486 |
/** |
| 487 |
* Construct a collector. |
| 488 |
* |
| 489 |
* A collector is used to register interest in events produced by one |
| 490 |
* or more ::pn_connection_t objects. Collectors are not currently |
| 491 |
* thread safe, so synchronization must be used if they are to be |
| 492 |
* shared between multiple connection objects. |
| 493 |
*/ |
| 494 |
PN_EXTERN pn_collector_t *pn_collector(void); |
| 495 |
|
| 496 |
/** |
| 497 |
* Free a collector. |
| 498 |
* |
| 499 |
* @param[in] collector a collector to free, or NULL |
| 500 |
*/ |
| 501 |
PN_EXTERN void pn_collector_free(pn_collector_t *collector); |
| 502 |
|
| 503 |
/** |
| 504 |
* Release a collector. Once in a released state a collector will |
| 505 |
* drain any internally queued events (thereby releasing any pointers |
| 506 |
* they may hold), shrink it's memory footprint to a minimum, and |
| 507 |
* discard any newly created events. |
| 508 |
* |
| 509 |
* @param[in] collector a collector object |
| 510 |
*/ |
| 511 |
PN_EXTERN void pn_collector_release(pn_collector_t *collector); |
| 512 |
|
| 513 |
/** |
| 514 |
* Drain a collector: remove and discard all events. |
| 515 |
* |
| 516 |
* @param[in] collector a collector object |
| 517 |
*/ |
| 518 |
PN_EXTERN void pn_collector_drain(pn_collector_t *collector); |
| 519 |
|
| 520 |
/** |
| 521 |
* Place a new event on a collector. |
| 522 |
* |
| 523 |
* This operation will create a new event of the given type and |
| 524 |
* context and return a pointer to the newly created event. In some |
| 525 |
* cases an event of the given type and context can be elided. When |
| 526 |
* this happens, this operation will return a NULL pointer. |
| 527 |
* |
| 528 |
* @param[in] collector a collector object |
| 529 |
* @param[in] clazz class of the context |
| 530 |
* @param[in] context the event context |
| 531 |
* @param[in] type the event type |
| 532 |
* |
| 533 |
* @return a pointer to the newly created event or NULL if the event |
| 534 |
* was elided |
| 535 |
*/ |
| 536 |
|
| 537 |
PN_EXTERN pn_event_t *pn_collector_put(pn_collector_t *collector, |
| 538 |
const pn_class_t *clazz, void *context, |
| 539 |
pn_event_type_t type); |
| 540 |
|
| 541 |
/** |
| 542 |
* Access the head event contained by a collector. |
| 543 |
* |
| 544 |
* This operation will continue to return the same event until it is |
| 545 |
* cleared by using ::pn_collector_pop. The pointer return by this |
| 546 |
* operation will be valid until ::pn_collector_pop is invoked or |
| 547 |
* ::pn_collector_free is called, whichever happens sooner. |
| 548 |
* |
| 549 |
* @param[in] collector a collector object |
| 550 |
* @return a pointer to the head event contained in the collector |
| 551 |
*/ |
| 552 |
PN_EXTERN pn_event_t *pn_collector_peek(pn_collector_t *collector); |
| 553 |
|
| 554 |
/** |
| 555 |
* Remove the head event on a collector. |
| 556 |
* |
| 557 |
* @param[in] collector a collector object |
| 558 |
* @return true if the event was popped, false if the collector is empty |
| 559 |
*/ |
| 560 |
PN_EXTERN bool pn_collector_pop(pn_collector_t *collector); |
| 561 |
|
| 562 |
/** |
| 563 |
* Pop and return the head event, returns NULL if the collector is empty. |
| 564 |
* The returned pointer is valid till the next call of pn_collector_next(). |
| 565 |
* |
| 566 |
* @param[in] collector a collector object |
| 567 |
* @return the next event. |
| 568 |
*/ |
| 569 |
PN_EXTERN pn_event_t *pn_collector_next(pn_collector_t *collector); |
| 570 |
|
| 571 |
/** |
| 572 |
* Return the same pointer as the most recent call to pn_collector_next(). |
| 573 |
* |
| 574 |
* @param[in] collector a collector object |
| 575 |
* @return a pointer to the event returned by previous call to pn_collector_next() |
| 576 |
*/ |
| 577 |
PN_EXTERN pn_event_t *pn_collector_prev(pn_collector_t *collector); |
| 578 |
|
| 579 |
/** |
| 580 |
* Check if there are more events after the current head event. If this |
| 581 |
* returns true, then pn_collector_peek() will return an event even |
| 582 |
* after pn_collector_pop() is called. |
| 583 |
* |
| 584 |
* @param[in] collector a collector object |
| 585 |
* @return true if the collector has more than the current event |
| 586 |
*/ |
| 587 |
PN_EXTERN bool pn_collector_more(pn_collector_t *collector); |
| 588 |
|
| 589 |
/** |
| 590 |
* Get the type of an event. |
| 591 |
* |
| 592 |
* @param[in] event an event object |
| 593 |
* @return the type of the event |
| 594 |
*/ |
| 595 |
PN_EXTERN pn_event_type_t pn_event_type(pn_event_t *event); |
| 596 |
|
| 597 |
/** |
| 598 |
* Get the class associated with the event context. |
| 599 |
* |
| 600 |
* @param[in] event an event object |
| 601 |
* @return the class associated with the event context |
| 602 |
*/ |
| 603 |
PN_EXTERN const pn_class_t *pn_event_class(pn_event_t *event); |
| 604 |
|
| 605 |
/** |
| 606 |
* Get the context associated with an event. |
| 607 |
*/ |
| 608 |
PN_EXTERN void *pn_event_context(pn_event_t *event); |
| 609 |
|
| 610 |
/** |
| 611 |
* Get the connection associated with an event. |
| 612 |
* |
| 613 |
* @param[in] event an event object |
| 614 |
* @return the connection associated with the event (or NULL) |
| 615 |
*/ |
| 616 |
PN_EXTERN pn_connection_t *pn_event_connection(pn_event_t *event); |
| 617 |
|
| 618 |
/** |
| 619 |
* Get the session associated with an event. |
| 620 |
* |
| 621 |
* @param[in] event an event object |
| 622 |
* @return the session associated with the event (or NULL) |
| 623 |
*/ |
| 624 |
PN_EXTERN pn_session_t *pn_event_session(pn_event_t *event); |
| 625 |
|
| 626 |
/** |
| 627 |
* Get the link associated with an event. |
| 628 |
* |
| 629 |
* @param[in] event an event object |
| 630 |
* @return the link associated with the event (or NULL) |
| 631 |
*/ |
| 632 |
PN_EXTERN pn_link_t *pn_event_link(pn_event_t *event); |
| 633 |
|
| 634 |
/** |
| 635 |
* Get the delivery associated with an event. |
| 636 |
* |
| 637 |
* @param[in] event an event object |
| 638 |
* @return the delivery associated with the event (or NULL) |
| 639 |
*/ |
| 640 |
PN_EXTERN pn_delivery_t *pn_event_delivery(pn_event_t *event); |
| 641 |
|
| 642 |
/** |
| 643 |
* Get the transport associated with an event. |
| 644 |
* |
| 645 |
* @param[in] event an event object |
| 646 |
* @return the transport associated with the event (or NULL) |
| 647 |
*/ |
| 648 |
PN_EXTERN pn_transport_t *pn_event_transport(pn_event_t *event); |
| 649 |
|
| 650 |
/** |
| 651 |
* Get any attachments associated with an event. |
| 652 |
* |
| 653 |
* @param[in] event an event object |
| 654 |
* @return the record holding the attachments |
| 655 |
*/ |
| 656 |
PN_EXTERN pn_record_t *pn_event_attachments(pn_event_t *event); |
| 657 |
|
| 658 |
/** |
| 659 |
* If the event context object has a condition and the condition is set |
| 660 |
* return it, otherwise return NULL. |
| 661 |
* If the event context object has remote and local conditions, |
| 662 |
* try the remote condition first, then the local. |
| 663 |
*/ |
| 664 |
PN_EXTERN struct pn_condition_t *pn_event_condition(pn_event_t *event); |
| 665 |
|
| 666 |
#ifdef __cplusplus |
| 667 |
} |
| 668 |
#endif |
| 669 |
|
| 670 |
/** |
| 671 |
* @} |
| 672 |
*/ |
| 673 |
|
| 674 |
#endif /* event.h */ |