266.6. 예
266.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");
266.6.2. 실행 이벤트 aka BLOCKS 이벤트 처리기 링크 복사링크가 클립보드에 복사되었습니다!
호출할 수 있는 모든 유형의 서버리스 함수는 https://www.pubnub.com/blocks-catalog/ 을 참조하십시오. geolocation 조회의 예
266.6.3. 이벤트 구독 링크 복사링크가 클립보드에 복사되었습니다!
다음 스니펫에서는 iot 채널에서 이벤트를 수신 대기합니다. Presens를 사용하여 옵션을 추가할 수 있는 경우 채널 참여, Leave asf 이벤트도 수신합니다.
from("pubnub:iot?subscribeKey=mySubscribeKey") .log("${body}") .to("mock:result");
from("pubnub:iot?subscribeKey=mySubscribeKey")
.log("${body}")
.to("mock:result");
266.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 계정이 필요합니다.
예제 PubNubSensorECDHE에는 이미 PubNub에서 제공하는 구독 키가 포함되어 있으므로 계정없이 실행할 수 있습니다. 예에서는 센서 데이터의 무한 스트림을 구독하는 PubNub 구성 요소를 보여줍니다.