本文整理汇总了Java中com.pubnub.api.PubnubException类的典型用法代码示例。如果您正苦于以下问题:Java PubnubException类的具体用法?Java PubnubException怎么用?Java PubnubException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PubnubException类属于com.pubnub.api包,在下文中一共展示了PubnubException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listenToMessages
import com.pubnub.api.PubnubException; //导入依赖的package包/类
private void listenToMessages() {
try {
pb = new Pubnub(PUBNUB_PUB_KEY, PUBNUB_SUB_KEY);
pb.subscribe(tokenPrefix + uniqueId, new Callback() {
@Override
public void successCallback(String channel, Object message, String timetoken) {
if(message instanceof String) {
pendingAck.remove(channel);
return;
}
Message m = new Message((JSONObject)message);
pb.publish(tokenPrefix + m.getSenderId(), "ACK", new Callback() {});
Display.getInstance().callSerially(() -> {
addMessage(m);
respond(m);
});
}
});
} catch(PubnubException err) {
Log.e(err);
Dialog.show("Error", "There was a communication error: " + err, "OK", null);
}
}
示例2: subscribe
import com.pubnub.api.PubnubException; //导入依赖的package包/类
@Override
public void subscribe(String channelName, LocationChannelListener listener)
throws LocationChannelException {
if (TextUtils.isEmpty(channelName)) {
throw new IllegalArgumentException("channelName must be non empty");
}
if (listener == null) {
throw new IllegalArgumentException("listener must be non null");
}
unsubscribe();
mListener = listener;
mCurrentChannel = channelName;
try {
mPubNub.subscribe(mCurrentChannel, mCallback);
} catch (PubnubException e) {
throw new LocationChannelException("subscribe failed", e);
}
}
示例3: presence
import com.pubnub.api.PubnubException; //导入依赖的package包/类
/**
* Listen to presence events for a channel. Accepts a listener and channel and
* registers for presence events. TODO://REFACTOR..
*
* @param roomName
* @param presenceListener
*/
public void presence(String roomName, final ChatterBoxCallback presenceListener) {
List<ChatterBoxCallback> listeners = new ArrayList<ChatterBoxCallback>();
listeners.add(presenceListener);
HashMap<String, UserProfile> presenceCache =
chatterBoxService.getPresenceCache();
Pubnub pubnub = chatterBoxService.getPubNub();
try {
pubnub.presence(roomName, new PresenceCallback(listeners, pubnub, presenceCache));
} catch (PubnubException e) {
Log.e(Constants.LOGT, "exception while attempting to register for presence", e);
}
}
示例4: subscribe
import com.pubnub.api.PubnubException; //导入依赖的package包/类
private void subscribe(String channel){
try {
mPubNub.subscribe(channel, this.mSubscribeReceiver);
} catch (PubnubException e){
e.printStackTrace();
}
}