当前位置: 首页>>代码示例>>Java>>正文


Java PubnubException类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:codenameone,项目名称:codenameone-demos,代码行数:24,代码来源:SocialChat.java

示例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);
    }
}
 
开发者ID:IndoorAtlas,项目名称:android-sdk-examples,代码行数:22,代码来源:PubNubLocationChannelImpl.java

示例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);
    }
}
 
开发者ID:groupflix,项目名称:android-pubnub-example,代码行数:25,代码来源:ChatterBoxClient.java

示例4: subscribe

import com.pubnub.api.PubnubException; //导入依赖的package包/类
private void subscribe(String channel){
    try {
        mPubNub.subscribe(channel, this.mSubscribeReceiver);
    } catch (PubnubException e){
        e.printStackTrace();
    }
}
 
开发者ID:newbie007fx,项目名称:newwebrtc,代码行数:8,代码来源:PnPeerConnectionClient.java


注:本文中的com.pubnub.api.PubnubException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。