diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-01-21 21:03:45 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-01-21 21:03:45 +0000 |
commit | 1e83b104b323d90664e90af7a12166308ba6ee7a (patch) | |
tree | a03f1585823fefa7d129a0bb11f62e87985668d5 /src/include | |
parent | 3c85fbac0a477a3f364da4eba7fe94a57d6eab1b (diff) | |
download | gnunet-1e83b104b323d90664e90af7a12166308ba6ee7a.tar.gz gnunet-1e83b104b323d90664e90af7a12166308ba6ee7a.zip |
towards a new conveniance API
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_server_lib.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/include/gnunet_server_lib.h b/src/include/gnunet_server_lib.h index ecfead5ab..100dc9659 100644 --- a/src/include/gnunet_server_lib.h +++ b/src/include/gnunet_server_lib.h | |||
@@ -138,6 +138,8 @@ struct GNUNET_SERVER_Handle *GNUNET_SERVER_create (struct | |||
138 | 138 | ||
139 | /** | 139 | /** |
140 | * Free resources held by this server. | 140 | * Free resources held by this server. |
141 | * | ||
142 | * @param s server to destroy | ||
141 | */ | 143 | */ |
142 | void GNUNET_SERVER_destroy (struct GNUNET_SERVER_Handle *s); | 144 | void GNUNET_SERVER_destroy (struct GNUNET_SERVER_Handle *s); |
143 | 145 | ||
@@ -192,6 +194,7 @@ struct GNUNET_CONNECTION_TransmitHandle | |||
192 | * @param client client we were processing a message of | 194 | * @param client client we were processing a message of |
193 | * @param success GNUNET_OK to keep the connection open and | 195 | * @param success GNUNET_OK to keep the connection open and |
194 | * continue to receive | 196 | * continue to receive |
197 | * GNUNET_NO to close the connection (normal behavior) | ||
195 | * GNUNET_SYSERR to close the connection (signal | 198 | * GNUNET_SYSERR to close the connection (signal |
196 | * serious error) | 199 | * serious error) |
197 | */ | 200 | */ |
@@ -414,6 +417,18 @@ void GNUNET_SERVER_disconnect_notify (struct GNUNET_SERVER_Handle *server, | |||
414 | 417 | ||
415 | 418 | ||
416 | /** | 419 | /** |
420 | * Ask the server to stop notifying us whenever a client disconnects. | ||
421 | * | ||
422 | * @param server the server manageing the clients | ||
423 | * @param callback function to call on disconnect | ||
424 | * @param callback_cls closure for callback | ||
425 | */ | ||
426 | void GNUNET_SERVER_disconnect_notify_cancel (struct GNUNET_SERVER_Handle *server, | ||
427 | GNUNET_SERVER_DisconnectCallback | ||
428 | callback, void *callback_cls); | ||
429 | |||
430 | |||
431 | /** | ||
417 | * Ask the server to disconnect from the given client. | 432 | * Ask the server to disconnect from the given client. |
418 | * This is the same as returning GNUNET_SYSERR from a message | 433 | * This is the same as returning GNUNET_SYSERR from a message |
419 | * handler, except that it allows dropping of a client even | 434 | * handler, except that it allows dropping of a client even |
@@ -440,6 +455,7 @@ GNUNET_SERVER_ignore_shutdown (struct GNUNET_SERVER_Handle *h, | |||
440 | int do_ignore); | 455 | int do_ignore); |
441 | 456 | ||
442 | 457 | ||
458 | |||
443 | /** | 459 | /** |
444 | * The tansmit context is the key datastructure for a conveniance API | 460 | * The tansmit context is the key datastructure for a conveniance API |
445 | * used for transmission of complex results to the client followed | 461 | * used for transmission of complex results to the client followed |
@@ -490,6 +506,81 @@ GNUNET_SERVER_transmit_context_run (struct GNUNET_SERVER_TransmitContext *tc, | |||
490 | 506 | ||
491 | 507 | ||
492 | 508 | ||
509 | /** | ||
510 | * The notification context is the key datastructure for a conveniance | ||
511 | * API used for transmission of notifications to the client until the | ||
512 | * client disconnects (or the notification context is destroyed, in | ||
513 | * which case we disconnect these clients). Essentially, all | ||
514 | * (notification) messages are queued up until the client is able to | ||
515 | * read them. | ||
516 | */ | ||
517 | struct GNUNET_SERVER_NotificationContext; | ||
518 | |||
519 | |||
520 | /** | ||
521 | * Create a new notification context. | ||
522 | * | ||
523 | * @param server server for which this function creates the context | ||
524 | * @param queue_length maximum number of messages to keep in | ||
525 | * the notification queue; optional messages are dropped | ||
526 | * it the queue gets longer than this number of messages | ||
527 | * @return handle to the notification context | ||
528 | */ | ||
529 | struct GNUNET_SERVER_NotificationContext * | ||
530 | GNUNET_SERVER_notification_context_create (struct GNUNET_SERVER_Handle *server, | ||
531 | unsigned int queue_length); | ||
532 | |||
533 | |||
534 | /** | ||
535 | * Destroy the context, force disconnect for all clients. | ||
536 | * | ||
537 | * @param nc context to destroy. | ||
538 | */ | ||
539 | void | ||
540 | GNUNET_SERVER_notification_context_destroy (struct GNUNET_SERVER_NotificationContext *nc); | ||
541 | |||
542 | |||
543 | /** | ||
544 | * Add a client to the notification context. | ||
545 | * | ||
546 | * @param nc context to modify | ||
547 | * @param client client to add | ||
548 | */ | ||
549 | void | ||
550 | GNUNET_SERVER_notification_context_add (struct GNUNET_SERVER_NotificationContext *nc, | ||
551 | struct GNUNET_SERVER_Client *client); | ||
552 | |||
553 | |||
554 | /** | ||
555 | * Send a message to a particular client; must have | ||
556 | * already been added to the notification context. | ||
557 | * | ||
558 | * @param nc context to modify | ||
559 | * @param client client to transmit to | ||
560 | * @param msg message to send | ||
561 | * @param can_drop can this message be dropped due to queue length limitations | ||
562 | */ | ||
563 | void | ||
564 | GNUNET_SERVER_notification_context_unicast (struct GNUNET_SERVER_NotificationContext *nc, | ||
565 | struct GNUNET_SERVER_Client *client, | ||
566 | const struct GNUNET_MessageHeader *msg, | ||
567 | int can_drop); | ||
568 | |||
569 | |||
570 | /** | ||
571 | * Send a message to all clients of this context. | ||
572 | * | ||
573 | * @param nc context to modify | ||
574 | * @param msg message to send | ||
575 | * @param can_drop can this message be dropped due to queue length limitations | ||
576 | */ | ||
577 | void | ||
578 | GNUNET_SERVER_notification_context_broadcast (struct GNUNET_SERVER_NotificationContext *nc, | ||
579 | const struct GNUNET_MessageHeader *msg, | ||
580 | int can_drop); | ||
581 | |||
582 | |||
583 | |||
493 | #if 0 /* keep Emacsens' auto-indent happy */ | 584 | #if 0 /* keep Emacsens' auto-indent happy */ |
494 | { | 585 | { |
495 | #endif | 586 | #endif |