Alljoyn Server is crashed after auto login

asked 2015-08-24 07:13:21 -0800

anonymous user

Anonymous

updated 2015-08-25 10:02:22 -0800

ry.jones gravatar image
Linux Foundation Staff

I am trying to implement alljoyn chat application in my android application. I am also implementing auto login feature with may application. Now I am facing a problem. When I am repeatedly connect and logout with alljoyn server, its work fine. But when I am trying to kill my application and reopen/restart it, then crash the Server. please help me. Thanks in advance.

Login Code:

    uName = txtLoginUserName.getText().toString().trim();
    uPass = txtUserPassword.getText().toString().trim();

    mChatApplication = (ChatApplication) getApplication();
    mChatApplication.checkin();

    mChatApplication.addObserver(this);

    mChatApplication.useSetChannelName("chat");
    mChatApplication.useJoinChannel();

    mWaitDlg = new WaitDialog(LoginActivity.this);
    mWaitDlg.setMessage("Please Wait...");
    mWaitDlg.show();

    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {

            mWaitDlg.dismiss();
            mChatApplication.newLocalUserMessage("{\"Type\":\"Request\",\"Device\":\"Android\",\"DeviceId\":\""
                    + Secure.getString(getContentResolver(),
                            Secure.ANDROID_ID)
                    + "\",\"Function\":\"Login\",\"UserName\":\""
                    + uName
                    + "\",\"Password\":\"" + uPass + "\"}");
        }
    }, 3000);
}

Logout Code:

mChatApplication
            .newLocalUserMessage("{\"Type\":\"Request\",\"Device\":\"Android\",\"DeviceId\":\""
                    + Secure.getString(getContentResolver(),
                            Secure.ANDROID_ID)
                    + "\",\"Function\":\"UserLogOut\",\"UserName\":\""
                    + MainActivity.mainInstance.gLogin_name
                    + "\",\"ApiKey\":\""
                    + MainActivity.mainInstance.gApi_key + "\"}");

    // Global.logout="userlogout";
    // Toast.makeText(SettingActivity.this, "Log Out Clicked",
    // Toast.LENGTH_LONG).show();

    BaseTask.run(new TaskListener() {
        @Override
        public Object onTaskRunning(int taskId, Object data) {
            return Server.logout();

            // return updateHistory();
        }

        @Override
        public void onTaskResult(int taskId, Object result) {
            if (mWaitDlg != null) {
                mWaitDlg.dismiss();
                mWaitDlg = null;
            }
            // Toast.makeText(SettingActivity.this, "result >> " + result +
            // " & " +taskId, Toast.LENGTH_SHORT).show();
            onLogoutResult(result);
        }

        @Override
        public void onTaskProgress(int taskId, Object... values) {

        }

        @Override
        public void onTaskPrepare(int taskId, Object data) {
            mWaitDlg = new WaitDialog(SettingActivity.this);
            mWaitDlg.setMessage("Logout...");
            mWaitDlg.show();
        }

        @Override
        public void onTaskCancelled(int taskId) {
        }
    });

Another Disconnect method I am trying:

Just leave the channel and redirect in login page with a string value.

mChatApplication.useLeaveChannel();
mChatApplication = (ChatApplication) getApplication();
mChatApplication.deleteObserver(ScanActivity.this);
Intent intent = new Intent(ScanActivity.this, LoginActivity.class);
intent.putExtra("logout", "userlogout");
startActivity(intent);
edit retag flag offensive close merge delete

Comments

you might try on the core mailing list. https://lists.allseenalliance.org/mailman/listinfo/allseen-core

ry.jones ( 2015-08-25 09:20:04 -0800 )edit