267.6. 例
267.6.1. イベントの公開
生成時のデフォルトの動作。次のスニペットは、PojoBean によって生成されたイベントをチャネル iot に発行します。
from("timer:mytimer")
    // generate some data as POJO.
    .bean(PojoBean.class)
    .to("pubnub:iot?publishKey=mypublishKey");
from("timer:mytimer")
    // generate some data as POJO.
    .bean(PojoBean.class)
    .to("pubnub:iot?publishKey=mypublishKey");267.6.2. BLOCKS イベントハンドラーとも呼ばれる Fire イベント
呼び出すことができるすべての種類のサーバーレス関数は、https://www.pubnub.com/blocks-catalog/ を参照してください。位置情報検索の例
267.6.3. イベントのサブスクライブ
次のスニペットは、iot チャネルでイベントをリッスンします。オプション withPresens を追加できる場合は、チャネルの Join、Leave asf イベントも受信します。
from("pubnub:iot?subscribeKey=mySubscribeKey")
    .log("${body}")
    .to("mock:result");
from("pubnub:iot?subscribeKey=mySubscribeKey")
    .log("${body}")
    .to("mock:result");267.6.4. 操作の実行
herenow : チャネルに現在サブスクライブしている一意のユーザー ID のリストや、チャネルの合計占有数など、チャネルの現在の状態に関する情報を取得します。
from("direct:control")
    .to("pubnub:myChannel?publishKey=mypublishKey&subscribeKey=mySubscribeKey&operation=herenow")
    .to("mock:result");
from("direct:control")
    .to("pubnub:myChannel?publishKey=mypublishKey&subscribeKey=mySubscribeKey&operation=herenow")
    .to("mock:result");wherenow : uuid がサブスクライブされているチャネルの現在のリストに関する情報を取得します
from("direct:control")
    .to("pubnub:myChannel?publishKey=mypublishKey&subscribeKey=mySubscribeKey&operation=wherenow&uuid=spyonme")
    .to("mock:result");
from("direct:control")
    .to("pubnub:myChannel?publishKey=mypublishKey&subscribeKey=mySubscribeKey&operation=wherenow&uuid=spyonme")
    .to("mock:result");setstate : サブスクライバー uuid に固有のキーと値のペアを設定するために使用されます。
from("direct:control")
    .bean(StateGenerator.class)
    .to("pubnub:myChannel?publishKey=mypublishKey&subscribeKey=mySubscribeKey&operation=setstate&uuid=myuuid");
from("direct:control")
    .bean(StateGenerator.class)
    .to("pubnub:myChannel?publishKey=mypublishKey&subscribeKey=mySubscribeKey&operation=setstate&uuid=myuuid");gethistory : チャネルの履歴メッセージを取得します。
from("direct:control")
    .to("pubnub:myChannel?publishKey=mypublishKey&subscribeKey=mySubscribeKey&operation=gethistory");
from("direct:control")
    .to("pubnub:myChannel?publishKey=mypublishKey&subscribeKey=mySubscribeKey&operation=gethistory");テストディレクトリーには、PubNub 機能のいくつかを示す例がいくつかあります。パブリッシュキーとサブスクライブキーを取得できる PubNub アカウントが必要です。
PubNubSensorExample の例には、PubNub によって提供されたサブスクライブキーがすでに含まれているため、これはアカウントなしで実行する準備ができています。この例は、センサーデータの無限ストリームにサブスクライブする PubNub コンポーネントを示しています。