3

I am working with QuickBlox library for video chat. How can i manage it session?? because when i move to the next activity from the live chat activity i just lost the session because it says "Chat can't initialized" then i have to create the session again to do the calling. So what's the lifetime of quickblox session and how can i manage that.

I am also facing problem with recalling when stop the call or move to the next activity and try to recall i was not able to do that actually i tried different things so each time i am getting different errors. So if any one has experience with QuickBlox library need help here.

When i stop a 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 do the 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");
    }
}
umerk44
  • 2,797
  • 4
  • 23
  • 43

1 Answers1

4

For: Lifetime of quickblox session and how can i manage that.

To authenticate your application you have to set valid a auth_key and generate a signature using your application auth_secret and receive a session token which you should use to send requests to QuickBlox API

And,

Expiration time for token is 2 hours. Please, be aware about it. If you will perform query with expired token - you will receive error Required session does not exist.

Source: Authentication and Authorization Session Info

That part fits the Android sample code of creating the 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 it still needs some work, esp to reach a stage equivalent to the iOS SDK and REST API.

Though looking at your code, you should use getToken() before creating the 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 a general manner, write the functions in onSuccess() of session creation if the session needs to be recreated.

Fyi, for the multiple ones, you can try checking the error with the summary that has been given, categorized into 4; ..developers/Errors

Pararth
  • 8,114
  • 4
  • 34
  • 51
  • Great that was helpful but that's the half answer of my question – umerk44 Jan 07 '15 at 12:51
  • Recalling? when participant stop the call and try to call again call doesn't accepted by other participant – umerk44 Jan 07 '15 at 12:52
  • pls explain the second paragraph more clearly, i didn't understand what you mean – Pararth Jan 07 '15 at 12:52
  • please check this http://stackoverflow.com/questions/27819697/quickblox-callback-when-participant-get-away-or-stopped-the-call – umerk44 Jan 07 '15 at 12:55
  • will take a look at that, it is good that you have asked a different question but then pls remove that part from this question to avoid redundancy and/or duplicate questions, then you can accept answers acc to the solution that helps – Pararth Jan 07 '15 at 12:59
  • 1
    can u plz explain how to continue session with token? i m using android sdk and the apis like http:api.quickbloz.session.json is not exposed directly hence i cannot send token with every rest api since its quickblox jar who hits this and is not directky exposed . I tried creating session with `createSessionWithExistanceToken` but i got session created and call wasnt able to receive . Please explain more in detail for this answer – KOTIOS Jan 18 '16 at 04:54
  • hi..i'd need to check the updates in quickblox now, have not been using it from some time, if i come across it, will update it here – Pararth Jan 18 '16 at 04:58
  • @user2450263 ok , but m interserted in knowing the time when you used how you managed to use token to create session on other activities. – KOTIOS Jan 18 '16 at 05:15