Quickblox is controlling the session and making the call?

I am working with the QuickBlox video chat library. How can I manage a session? because when i go to next activity from active chat activity i just lost the session because it says "chat could not be initialized" then i need to create session again to call. So what is the lifetime in a quickblox session and how can I do it.

I also run into a recall issue when I stop a call or go to the next step and try to remember that I couldn't do it, I tried different things, so every time I get different errors. So if anyone has any experience with the QuickBlox library, you need help.

When I leave the call, I call this function.

private void stopCall() {

        //Toggle view show the smile view again

        //ToggleSmileView();

        try
        {
            cancelCallTimer();

            if (videoChat != null) {
                videoChat.stopCall();
                videoChat = null;
            }
            if (videoChannel != null) {
                videoChannel.close();
                videoChannel = null;
            }

            sessionId = null;
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }

      

and when i make a call i call this function

 private void call() {

    //toggle view 
    //ToggleSmileView();

    // get opponent
    //
    VideoChatApplication app = (VideoChatApplication)getApplication();
    opponent = new QBUser();
    opponent.setId((app.getCurrentUser().getId() == VideoChatApplication.FIRST_USER_ID ? VideoChatApplication.SECOND_USER_ID : VideoChatApplication.FIRST_USER_ID));

    // call
    //
    callTimer = new Timer();
    callTimer.schedule(new CancelCallTimerTask(), 30 * 1000);

    createSenderChannel();
    initVideoChat();

    if (videoChat != null) 
    {
        videoChat.call(opponent, getCallType(), 3000);
        //toggleMicrophoneMute();
    } 
    else 
    {
        logAndToast("Stop current chat before call");
    }
}

      

+3


source to share


1 answer


For: Quickblox session lifetime and how can I manage it.

To authenticate your app, you must set a valid auth_key and generate a signature using your app auth_secret and get a session token that you must use to send requests to the QuickBlox API

AND,

Token validity period is 2 hours. Please stay informed. If you run a request with an expired token, you will receive an error Required session does not exist.

Source: Authentication and Authorization Session Information

This part follows the sample code for creating an Android session,



QBAuth.createSession(new QBEntityCallbackImpl<QBSession>() {
    @Override
     public void onSuccess(QBSession session, Bundle params) {
        Log.i(TAG, "session created, token = " + session.getToken());
     }
     @Override
     public void onError(List<String> errors) {

     }
});

      

Source: Android Developers Documentation

I have worked with the Android SDK and feel like it still needs some work, for example to achieve a level equivalent to the IOS SDK and REST API.

If you look at your code you should use getToken()

before creating new QBUser

and related video chat calls, if the token has expired, just create a new one. I have implemented similar code, not a video chat application, but in general I will write functions in onSuccess()

creating a session if the session needs to be recreated.

Fyi, for a few, you can try to check the error with the provided sum, classified by 4; .. developers / bugs

+4


source







All Articles