Skip to content

Instantly share code, notes, and snippets.

@anovikov1984
Created February 1, 2017 18:09
Show Gist options
  • Save anovikov1984/c7430eb3c5b46f3d5aa8034edf230d16 to your computer and use it in GitHub Desktop.
Save anovikov1984/c7430eb3c5b46f3d5aa8034edf230d16 to your computer and use it in GitHub Desktop.
public void testSub() throws PubNubException, InterruptedException {
PNConfiguration pnConfiguration = new PNConfiguration();
pnConfiguration.setSubscribeKey("demo");
pnConfiguration.setPublishKey("demo");
PubNub pubnub = new PubNub(pnConfiguration);
pubnub.addListener(new SubscribeCallback() {
@Override
public void status(PubNub pubnub, PNStatus status) {
}
@Override
public void message(PubNub pubnub, PNMessageResult message) {
System.out.println(message);
}
@Override
public void presence(PubNub pubnub, PNPresenceEventResult presence) {
}
});
pubnub.subscribe().channels(Arrays.asList("blah")).execute();
// You need to wait for any subscribe callback on you own, for ex:
// Thread.sleep(1000*1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment