Could you please gi...
 
Notifications
Clear all

Could you please give an example of how to obtain information from the server

5 Posts
2 Users
0 Reactions
897 Views
(@hsilva)
Posts: 22
Eminent Member
Topic starter
 

Hi.

I tried following the code in Start () of CombuManager, but I can not call it from my code, could you give an example please?

Thank you in advance.

 
Posted : 15/11/2017 6:49 am
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

CombuManager.Start is already called automatically, you only need to wait in your script for the initialization to be finished (client and server exchange security keys to crypt the parameters of webservices):

public class Test : MonoBehaviour {
	IEnumerator Start () {

		while (!CombuManager.isInitialized)
			yield return null;

		// now Combu has been initialized and can be used to login etc
		CombuManager.platform.Authenticate (username, password, (bool success, string error) => {
			Debug.Log("Login: " + success + " -- " + error);
		});
	}
}

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 15/11/2017 10:43 am
(@hsilva)
Posts: 22
Eminent Member
Topic starter
 

Hi. Thanks for your prompt response.

Sorry, I did not know how to ask my question. What I want is to use Combu to know the time of the server (server information), to validate restricted access per time (for a competition). I see that it is with GetServerInfo, but I can not understand how to call it from my own script. Could you please give an example?

Thank you in advance.

 
Posted : 15/11/2017 4:12 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

In the previous sample script after waiting for isInitialized you can access CombuManager.instance.serverInfo.time (it should be expressed in UTC), GetServerInfo is automatically called during initialization and the time is what it was during the initialization (in case you'd need to calculate some offset from date/time of clients).

Alternatively you can call GetServerInfo whenever you want (after CombuManager.isInitialized is true):

CombuManager.instance.GetServerInfo((bool success, CombuServerInfo info) =>
{
    if (success)
    {
        Debug.Log(info.time.ToString());
    }
});

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 15/11/2017 5:32 pm
(@hsilva)
Posts: 22
Eminent Member
Topic starter
 

It works perfectly, thank you very much!

 
Posted : 16/11/2017 4:43 am
Share: