Unfortunately I still get the error. I added a zip with a video that shows what I do. Hope it helps.
session_timout_clip.zip (2.3 MB)
Unfortunately I still get the error. I added a zip with a video that shows what I do. Hope it helps.
session_timout_clip.zip (2.3 MB)
I will install a newer version of Unity and try again.
Hello, @Joey_Fladderak.
I still don’t understand what your problem is. As far as I understood, you activated the timeout. After 10 seconds, the user token becomes invalid. And you need to re-login. I think this is expected behavior.
Code of my simple test project with many logs:
try
{
Debug.Log( "Find Processing..." );
var findRes = Backendless.Data.Of( "TestTable" ).Find()[ 0 ];
Debug.Log( "Find completed. Result: " + findRes[ "objectId" ] );
Debug.Log( "//////////////////////\nChecking Current User...." );
var resCurUser = Backendless.UserService.CurrentUser;
if( resCurUser != null )
{
Debug.Log( "Current User result: " + resCurUser.Email );
}
else
{
Debug.Log( "Current User is null. Reloggining...." );
var resLog = Backendless.UserService.Login( "hdhdhd@gmail.com", "123234", true );
Debug.Log( "Login completed. User Result: " + resLog.Email );
}
Debug.Log( "Trying to get data with logged in user..." );
var findLoggedIn = Backendless.Data.Of( "TestTable" ).Find()[ 0 ];
Debug.Log( "Task is completed. Result date of creation: " + findRes[ "created" ] );
}
catch( Exception ex )
{
Debug.Log( "ERRRRRROOOOOORRR: " + ex.Message );
Debug.Log( "Logout..." );
Backendless.UserService.LoginStorage.DeleteFiles(); // Also u can just call Backendless.UserService.Logout();
Debug.Log( "Loggin for new user session..." );
var resLog = Backendless.UserService.Login( "hdhdhd@gmail.com", "123234", true );
Debug.Log( "Login completed. User Result: " + resLog.Email );
Debug.Log( "Trying to get data with logged in user..." );
var findRes = Backendless.Data.Of( "TestTable" ).Find()[ 0 ];
Debug.Log( "Task is completed. Result date of creation: " + findRes[ "created" ] );
}
Best Regards, Nikita.
There was a problem with the fact that it was not possible to re-login the user. Due to the fact that the User token was not cleared, but I fixed it recently. Now everything seems to work as expected.
The problem is that I want to call
IList<Springloop.BackendlessData.Games> loadedGames = await Backendless.Data.Of<Springloop.BackendlessData.Games>().FindAsync();
Regardless if a user is logged in or not. Before I log in with a user, that call works just fine (no user logged in). When I log in with a user, it works fine as well (user is logged in)
Now, after 10 seconds, when the session of the logged in user is expired, I am suddenly not allowed to call that line again (session expired) and this is not the behaviour I expect.
I am allowed to call that line when no user is logged in, but not when a session is expired.
This is expected behavior. The token has been expired on the server, it is no longer valid. But since stayLoggedIn = true
in the sdk. The sdk still sends this token to the server. Because of this, a timeout error is returned. When the session has been expired just call this line:
Backendless.UserService.LoginStorage.DeleteFiles();
Alright, I will try that. For me it was unexpected behaviour as I treated the call as not user related because I can call it without being logged in.
It didn’t really make sense that the call would stop working after a session was expired if I would also be able to call it without being logged in, but I guess it’s a technical design.
So I guess I could check with Backendless.UserService.IsValidLogin()
is the session is still valid and if not, call Backendless.UserService.LoginStorage.DeleteFiles();
Yes, you can make requests if the token is null. But as soon as it is invalid, an error will be returned to you.
Alright, sorry for the headache this must’ve caused! But good to know this is the expected behaviour.
Your work is greatly appreciated