Autologin before Co...
 
Notifications
Clear all

Autologin before Combu Manager initialization

5 Posts
2 Users
0 Likes
307 Views
(@agm)
Posts: 6
Active Member
Topic starter
 

Hello

I have been reading the documentation and searching the forum but I didn´t find the answer. I´m really new with this amazing asset.

I have tried to set the autologin code in the start of a script in order to autologin when game starts:

string storedUsername, storedPassword;
if (User.CanAutoLogin(out storedUsername, out storedPassword))
{
User.AutoLogin((bool success, string error) => {
Debug.Log("AutoLogin: " + success + " -- " + error);
});
}

But I always have the same error:

Exception: Combu Manager not initialized

How can I know the Combu Manager state in order to wait until initialized to try the autologin?

Thank you very much

 
Posted : 21/06/2021 1:43 am
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

The reason is what the message says: you're calling this code before CombuManager component has been initialized (that is the initial connection has not been established).

You should use this code inside a coroutine, for example:

IEnumerator Start()
{
    while (!CombuManager.isInitialized)
        yield return new WaitForFixedUpdate();

    string storedUsername, storedPassword;
    if (User.CanAutoLogin(out storedUsername, out storedPassword))
    {
        User.AutoLogin((bool success, string error) => {
            Debug.Log("AutoLogin: " + success + " -- " + error);
        });
    }
}

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 21/06/2021 12:21 pm
(@agm)
Posts: 6
Active Member
Topic starter
 

Great. Many many thanks. Now it´s fine and autologin is working. I don´t know yet if autologin works different from authenticate but now the parsing to my own user class has an error. When i do

GameControl.player = CombuManager.localUser as MyPlayer;

says

NullReferenceException: Object reference not set to an instance of an object

but with the manual login there was no problem. 

Anyway, thank you very much for your great work.

 

 
Posted : 21/06/2021 3:54 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

Use the templated version of Autologin and pass your custom User class to it:

User.AutoLogin<MyPlayer>

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 21/06/2021 4:24 pm
(@agm)
Posts: 6
Active Member
Topic starter
 

Thank you very much. Something i´m still missing but don´t worry. I´m using many of your tools and learning so many things that probably I´m making something wrong because of my novelty. I am working fine with CombuManager.localUser.customData["mydata"] notation so i will come back to my own class later. This topic is answered so we can close it to avoid merge answers in a wrong title.

Thanks again for your time.

 
Posted : 21/06/2021 8:56 pm
Share: