QuickBlox android 会话用户信息为空 [英] QuickBlox android session userinfo is null

查看:51
本文介绍了QuickBlox android 会话用户信息为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用适用于 Android 23 API 的 quickblox.我想在呼叫建立之前将用户信息从一个呼叫者包含到另一个呼叫者.为此,我使用了 QBRTCSession 的userinfo"部分并放入了一个键值对.但对于另一端,它为userinfo"提供空值.任何人都可以提出可能的原因并提出解决方案吗?

I am using the quickblox for Android 23 API . I want to include user info from one caller to another, just before the call is established. For that I have used the 'userinfo' part of QBRTCSession and put in a key value pair. But for the other end, its giving null value for 'userinfo'. Could anyone please suggest the possible reason and suggest a solution?

两个调用中的会话 ID 相同.开始通话功能-

The session id is same in both the calls. Start call function-

  private void startCall(boolean isVideoCall) {
    if (opponentsAdapter.getSelectedItems().size() > Consts.MAX_OPPONENTS_COUNT) {
        Toaster.longToast(String.format(getString(R.string.error_max_opponents_count),
                Consts.MAX_OPPONENTS_COUNT));
        return;
    }
    Log.d(TAG
            , "startCall()");
    //ArrayList<Integer> opponentsList = CollectionsUtils.getIdsSelectedOpponents(opponentsAdapter.getSelectedItems());
    ArrayList<Integer> opponentsList = new ArrayList<>();
    opponentsList.add(currentOpponentsList.get(0).getId());
    QBRTCTypes.QBConferenceType conferenceType = isVideoCall
            ? QBRTCTypes.QBConferenceType.QB_CONFERENCE_TYPE_VIDEO
            : QBRTCTypes.QBConferenceType.QB_CONFERENCE_TYPE_AUDIO;
    QBRTCClient qbrtcClient = QBRTCClient.getInstance(getApplicationContext());
    QBRTCSession newQbRtcSession = qbrtcClient.createNewSessionWithOpponents(opponentsList, conferenceType);
    newQbRtcSession.getUserInfo().put("som","name");
    Log.v("SessionThing",newQbRtcSession.getSessionDescription().toString());

    WebRtcSessionManager.getInstance(this).setCurrentSession(newQbRtcSession);
 //   newQbRtcSession.

    PushNotificationSender.sendPushMessage(opponentsList, "Hello"+currentUser.getFullName());
    Toast.makeText(getApplicationContext(),name,Toast.LENGTH_LONG).show();
    CallActivity.start(this, false);

    Log.d(TAG, "conferenceType = " + conferenceType);
}

通话中活动-

  public void onReceiveNewSession(final QBRTCSession session) {
    Log.d("userinfo_needed", "Session " + session.getSessionID() + " are income");
    Log.v("qbrtcsession",session.getSessionDescription().toString());
    userInfo = session.getUserInfo();
    if (getCurrentSession() != null) {
        //userInfo = session.getUserInfo();
        Log.d(TAG, "Stop new session. Device now is busy");
        session.rejectCall(null);
    }
}

In IncomeCallFragment - Toast 给出 null

In IncomeCallFragment - The toast gives null

  private void initUI(View view) {
    callTypeTextView = (TextView) view.findViewById(R.id.call_type);

    ImageView callerAvatarImageView = (ImageView) view.findViewById(R.id.image_caller_avatar);
    callerAvatarImageView.setBackgroundDrawable(getBackgroundForCallerAvatar(currentSession.getCallerID()));

    TextView callerNameTextView = (TextView) view.findViewById(R.id.text_caller_name);

    QBUser callerUser = qbUserDbManager.getUserById(currentSession.getCallerID());
    callerNameTextView.setText(UsersUtils.getUserNameOrId(callerUser, currentSession.getCallerID()));
    Toast.makeText(getActivity().getApplicationContext(),currentSession.getSessionDescription().getUserInfo()+" ", Toast.LENGTH_LONG).show();
    TextView otherIncUsersTextView = (TextView) view.findViewById(R.id.text_other_inc_users);
    otherIncUsersTextView.setText(getOtherIncUsersNames());

    alsoOnCallText = (TextView) view.findViewById(R.id.text_also_on_call);
    setVisibilityAlsoOnCallTextView();

    rejectButton = (ImageButton) view.findViewById(R.id.image_button_reject_call);
    takeButton = (ImageButton) view.findViewById(R.id.image_button_accept_call);
    accept();
}

推荐答案

一旦你创建了 Session set The Map in session for start call :

Once you create the Session set The Map in session for start call :

public static Map<String,String> createSessionUserInfo(){
    // Make sure you do not add anything null in this Map. Otherwise it will throw Exception,
    // So add blank string instead of null
    Map<String,String> userInfo=new HashMap<>();
    userInfo.put("img_user" , "img_url_here");
    userInfo.put("name_user" , "name_here");
    return userInfo;
}

然后添加此信息以开始通话:

Then add this info to start call :

 Map<String,String> userInfo= createSessionUserInfo();
            currentCallSession.startCall(userInfo);

在对手端,您将在 onReceiveNewSession() 中接收此会话及其默认行为.:

On the Opponent end you will receive this session in onReceiveNewSession() and its the default behavior.:

 @Override
public void onReceiveNewSession(final QBRTCSession qbrtcSession) {
    try {
        Map<String, String> userSessionInfo = qbrtcSession.getUserInfo();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

如果您仍然遇到问题,请告诉我.

Let me know if you are still facing problem .

这篇关于QuickBlox android 会话用户信息为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆