前へ 目次 索引 DocHome 次へ |
iPlanet Calendar Server 5.1 イベント通知サービスマニュアル |
第 4 章 iPlanet Calendar Server 固有の情報
この章では、ENS API を使用するために必要となる iPlanet Calendar Server に固有の事柄について説明します。
iPlanet Calendar Server 通知
iPlanet Calendar Server 通知
iPlanet Calendar Server 通知の形式は、次の 2 つの部分に分かれています。
イベント参照 - イベントを識別する URL。
カレンダー通知には、リマインダを中継するアラーム通知と、カレンダーデータベースに変更を配信するカレンダー更新通知の、2 種類があります。 次に、両方の種類のカレンダー通知について説明します。ペイロード - イベントを記述するデータ。 バイナリ、テキスト/カレンダー、およびテキスト/XML の 3 種類のペイロード形式がサポートされています。
アラーム通知 これらの通知は、リマインダを中継します。 csadmind デーモンがリマインダを送信しようとするたびに公開されます。 iPlanet Messaging and Collaboration イベント通知サービスでは、これらのアラームのデフォルトのサブスクライバは、csnotifyd デーモンです。 csnotifyd がコンシュームする通知はバイナリペイロードを持ち、アクノリッジされます (高信頼)。
イベント URL パラメータに含まれる項目は次のとおりです。
カレンダー更新通知 これらの通知は、カレンダーデータベースに変更を配信します。 データベースに変更が加えられるたびに、cshttpd デーモンまたは csdwpd デーモンによって公開されます (このタイプの変更に対して通知が使用可能になっている場合)。
- また、追加の通知を各リマインダにつき 1 つ生成するようサーバを構成して、サードパーティの通知インフラストラクチャがコンシュームできるようにすることもできます。
- 表 4-1 に、2 種類のアラームを使用可能にする方法、そのベースイベント URI、および各アラームのイベントペイロード形式を示します (カレンダー通知の形式 参照)。
- イベント URL のパラメータは、次のいずれかと同じです。
- 表 4-2 に、各タイプのカレンダー更新通知と、それぞれの ics.conf 設定、ベースイベント URL を示します。
カレンダー通知の形式
通知は、次の 2 つの部分に分かれています。
iPlanet Calendar Server サンプルコード
iPlanet Calendar Server は、完全な ENS 実装を伴って出荷されています。ENS API を使用して iPlanet Calendar Server をカスタマイズすることができます。 次の 4 つのコードサンプル (簡単なパブリッシャとサブスクライバ、および信頼性の高いパブリッシャとサブスクライバ ) で、ENS API の使い方を示します。 コーディング例は、製品の次のディレクトリにあります。/opt/SUNWics5/cal/csapi/samples/ens
パブリッシャとサブスクライバのサンプルコード
次のコーディング例のペアでは、簡単な対話形式の非同期パブリッシャとサブスクライバを確立します。
* Copyright 2000 by Sun Microsystems, Inc.
* All rights reserved
*
* apub : 簡単な対話形式の非同期パブリッシャ
* 構文:
* apub ホストポート
*/#include <stdlib.h>
#include <stdio.h>#include "pasdisp.h"
#include "publisher.h"static pas_dispatcher_t *disp = NULL;
static publisher_t *_publisher = NULL;
static int _shutdown = 0;static void _exit_usage()
{
printf("\n使用法:\napub ホストポート\n");
exit(5);}static void _exit_error(const char *msg)
{
printf("%s\n", msg);
exit(1);}static void _call_shutdown()
{
_shutdown = 1;
pas_shutdown(disp);
}static void _open_ack(void *arg, int rc, void *enc)
{
_publisher = (publisher_t *)enc;
(void *)arg;if (!_publisher)
{
printf("状態 %d のため、パブリッシャの作成に失敗しました\n", rc);
_call_shutdown();
return;
}static void _publish_ack(void *arg, int rc, void *ignored)
{
(void *)ignored;printf("状態 %d のため、公開に失敗しました\n", rc);
if ( !fgets(input, sizeof(input), stdin) )
{
continue;} else {
char *message;
unsigned int message_len;input[strlen(input) - 1] = 0; /* \n を取り除く*/
if (*input == ヤ.ユ && input[1] == 0)
{
publisher_delete(_publisher);
_call_shutdown();
break;
}message = strdup(input);
message_len = strlen(message);
publish(_publisher, "enp://yoyo.com/xyz",message,
message_len,
_publish_ack, NULL, (void *)message, 0);
return;
}
}
return;
}main(int argc, char **argv)
{
unsigned short port = 7997;
char host[256];if (*(argv[1]) == ヤ0ユ)
{
strcpy(host, "127.0.0.1");
} else {
strcpy(host, argv[1]);
}if (argc > 2)
{
port = (unsigned short)atoi(argv[2]);
}
disp = pas_dispatcher_new(NULL);
if (disp == NULL) _exit_error("パブリッシャを作成できません");publisher_new_a(disp, NULL, host, port, _open_ack, disp);
サブスクライバのコードサンプル
/*
* Copyright 1997 by Sun Microsystems, Inc.
* All rights reserved
*
* asub : 非同期サブスクライバの例
*
* 構文:
* asub ホストポート
*/#include <stdlib.h>
#include <stdio.h>#include "pasdisp.h"
#include "subscriber.h"static pas_dispatcher_t *disp = NULL;
static subscriber_t *_subscriber = NULL;
static subscription_t *_subscription = NULL;
static renl_t *_renl = NULL;static void _exit_usage()
{
printf("\n使用法:\nasub ホストポート\n");
exit(5);static void _exit_error(const char *msg)
{
printf("%s\n", msg);
exit(1);
}static void _subscribe_ack(void *arg, int rc, void *subscription)
{
(void)arg;if (!rc)
{
_subscription = subscription;
printf("購読に成功しました\n");
} else {
printf("購読に失敗しました - 状態 %d\n", rc);
pas_shutdown(disp);
}
}static void _unsubscribe_ack(void *arg, int rc, void *ignored)
{if (rc != 0)
{
printf("購読の解除に失敗しました - 状態 %d\n", rc);
}subscriber_delete(_subscriber);
pas_shutdown(disp);
}static int _handle_notify(void *arg, char *url, char *str, int len)
{
(void *)arg;
printf("[%s] %.*s\n", url, len, (str) ? str : "(null)");
return 0;
}static void _open_ack(void *arg, int rc, void *enc)
{
_subscriber = (subscriber_t *)enc;(void *)arg;
if (rc)
{
printf("状態 %d のため、サブスクライバの作成に失敗しました\n", rc);
pas_shutdown(disp);
return;
}subscribe(_subscriber, "enp://yoyo.com/xyz",
_handle_notify, NULL,
_subscribe_ack, NULL);static void _unsubscribe(int sig)
{
(int)sig;
unsubscribe(_subscriber, _subscription, _unsubscribe_ack, NULL);
}main(int argc, char **argv)
{
unsigned short port = 7997;
char host[256];if (argc < 2) _exit_usage();
if (*(argv[1]) == ヤ0ユ)
{
strcpy(host, "127.0.0.1");
} else {
strcpy(host, argv[1]);
}
if (argc > 2)
{
port = (unsigned short)atoi(argv[2]);
}disp = pas_dispatcher_new(NULL);
if (disp == NULL) _exit_error("パブリッシャを作成できません");subscriber_new_a(disp, NULL, host, port, _open_ack, NULL);
信頼性の高いパブリッシャとサブスクライバ
次のコーディング例のペアでは、信頼性の高い非同期パブリッシャとサブスクライバを確立します。
信頼性の高いパブリッシャのコードサンプル
/*
* Copyright 2000 by Sun Microsystems, Inc.
* All rights reserved
*
* rpub : 簡単で *信頼性の高い* 対話形式の非同期パブリッシャ
* rsub (信頼性の高いサブスクライバ) と組み合わせて
* 使用するように設計されています。
*
* 構文:
* rpub ホストポート
*/#include <stdlib.h>
#include <stdio.h>#include "pasdisp.h"
#include "publisher.h"static pas_dispatcher_t *disp = NULL;
static publisher_t *_publisher = NULL;
static int _shutdown = 0;
static renl_t *_renl;printf("\n使用法:\nrpub ホストポート\n");
static void _exit_error(const char *msg)
{
printf("%s\n", msg);
exit(1);
}static void _call_shutdown()
{
_shutdown = 1;
pas_shutdown(disp);
}static void _renl_create_cb(void *arg, int rc, void *ignored)
{
(void *)arg;
(void *)ignored;if (!_publisher)
{
printf("RENL の作成に失敗しました - 状態 %d\n", rc);
_call_shutdown();
return;
}static void _publisher_new_cb(void *arg, int rc, void *enc)
{_publisher = (publisher_t *)enc;
if (!_publisher)
{
printf("パブリッシャの作成に失敗しました - 状態 %d\n", rc);
_call_shutdown();
return;
}renl_create_publisher(_publisher, "renl_id", NULL,
_renl_create_cb,NULL);static void _recv_ack(void *arg, int rc, void *ignored)
{
(void *)ignored;if (rc < 0)
{
printf("アクノリッジメントのタイムアウト\n");
} else if ( rc == 0) {
printf("アクノリッジメントを受信しました\n");
}
fflush (stdout);static void _read_stdin()
{
static char input[1024];printf("rpub> ");
fflush(stdout);
while (!_shutdown)
{
if ( !fgets(input, sizeof(input), stdin) )
{
continue;
} else {
char *message;
unsigned int message_len;input[strlen(input) - 1] = 0; /* \n を取り除く*/
if (*input == ヤ.ユ && input[1] == 0)
{
publisher_delete(_publisher);
_call_shutdown();
break;
}message = strdup(input);
message_len = strlen(message);/* タイムアウト 5 秒*/
publish(_publisher, "enp://yoyo.com/xyz",
message, message_len,
NULL, _recv_ack, message, 5000);main(int argc, char **argv)
{
unsigned short port = 7997;
char host[256];if (argc < 2) _exit_usage();
if (*(argv[1]) == ヤ0ユ)
{
strcpy(host, "127.0.0.1");
} else {
strcpy(host, argv[1]);
}if (argc > 2)
{
port = (unsigned short)atoi(argv[2]);
}disp = pas_dispatcher_new(NULL);
if (disp == NULL) _exit_error("パブリッシャを作成できません");publisher_new_a(disp, NULL, host, port, _publisher_new_cb,
NULL);
信頼性の高いサブスクライバのコードサンプル
/*
* Copyright 1997 by Sun Microsystems, Inc.
* All rights reserved
*
* asub : 非同期サブスクライバの例
*
* 構文:
* asub ホストポート
*/#include <stdlib.h>
#include <stdio.h>#include "pasdisp.h"
#include "subscriber.h"static pas_dispatcher_t *disp = NULL;
static subscriber_t *_subscriber = NULL;
static subscription_t *_subscription = NULL;
static renl_t *_renl = NULL;static void _exit_usage()
{
printf("\n使用法:\nasub ホストポート\n");
exit(5);
}static void _exit_error(const char *msg)
{printf("%s\n", msg);
exit(1);}static void _subscribe_ack(void *arg, int rc, void *subscription)
{
(void)arg;
if (!rc)
{
_subscription = subscription;
printf("購読に成功しました\n");
_renl = renl_create_subscriber(_subscription, "renl_id",
NULL);
} else {
printf("購読に失敗しました - 状態 %d\n", rc)
pas_shutdown(disp);
}
}static void _unsubscribe_ack(void *arg, int rc, void *ignored)
{
(void *)ignored;
(void *)arg;if (rc != 0)
{
printf("購読の解除に失敗しました - 状態 %d\n", rc);
}subscriber_delete(_subscriber);
pas_shutdown(disp);
}static int _handle_notify(void *arg, char *url, char *str, int len)
{
(void *)arg;
printf("[%s] %.*s\n", url, len, (str) ? str : "(null)");
return 0;
}static void _open_ack(void *arg, int rc, void *enc)
{
_subscriber = (subscriber_t *)enc;(void *)arg;
if (rc)
{
printf("状態 %d のため、サブスクライバの作成に失敗しました\n", rc);
pas_shutdown(disp);
return;
}subscribe(_subscriber, "enp://yoyo.com/xyz",_handle_notify,
NULL,_subscribe_ack, NULL);static void _unsubscribe(int sig)
{
(int)sig;
unsubscribe(_subscriber, _subscription, _unsubscribe_ack, NULL);
}main(int argc, char **argv)
{
unsigned short port = 7997;
char host[256];if (argc < 2) _exit_usage();
if (*(argv[1]) == ヤ0ユ)
{
strcpy(host, "127.0.0.1");
} else {
strcpy(host, argv[1]);
}
if (argc > 2)
{
port = (unsigned short)atoi(argv[2]);disp = pas_dispatcher_new(NULL);
if (disp == NULL) _exit_error("パブリッシャを作成できません");
subscriber_new_a(disp, NULL, host, port, _open_ack, NULL);
前へ 目次 索引 DocHome 次へ
Copyright (C) 2002 Sun Microsystems, Inc. Some preexisting portions Copyright (C) 2000 Netscape Communications Corp. All rights reserved.
最終更新日: 2002 年 1 月 31 日