// create a new session public void CreateNewSession(string game, string version) { if (!apiService) { return; } Dictionary <string, object> payload = new Dictionary <string, object>(); payload.Add("timeStart", EnableAPI.GetTimestamp()); payload.Add("game", game.ToLower()); payload.Add("version", version.ToLower()); payload.Add("location", "Home"); APIService.IRequest req = apiService.CreateRequest(APIService.RequestMethod.POST, this.endpoints["Session"], payload); CallAPI(req, this.callback, true); }
void Awake() { Debug.Log("EnableAPI:Awake:1"); if (instance != null) { Debug.Log("EnableAPI:Awake:2"); Destroy(this.gameObject); return; } else { Debug.Log("EnableAPI:Awake:3"); instance = this; } Debug.Log("EnableAPI:Awake:4"); this.gameObject.name = "_EnableAPI(Singleton)"; Debug.Log("EnableAPI:Awake:4.1"); DontDestroyOnLoad(this.gameObject); Debug.Log("EnableAPI:Awake:4.1.1"); //#if !UNITY_ANDROID || UNITY_EDITOR if (Application.platform != RuntimePlatform.Android) { Debug.Log("EnableAPI:Awake:4.2"); // read from command line which endpoint we should hit String[] arguments = Environment.GetCommandLineArgs(); foreach (string arg in arguments) { Debug.Log("EnableAPI:Awake:4.3"); // if the debug flag was given, switch to local endpoint if (arg.ToLower().StartsWith("/d")) { endpoint = localEndpoint; break; } } } //#endif Debug.Log("EnableAPI:Awake:5"); apiService = ScriptableObject.CreateInstance <APIService>(); Debug.Log("EnableAPI:Awake:6"); if (!apiService) { return; } Debug.Log("EnableAPI:Awake:7"); apiService.Init(endpoint); Debug.Log("EnableAPI:Awake:8"); sessionID = string.Empty; parameters = new Dictionary <string, string>(); if (socket != null) { socket.On("open", SocketOpen); socket.On("error", SocketError); socket.On("new object", SocketNewObject); socket.On("close", SocketClose); } if (RunTest) { callback = APICallback; StartCoroutine(TestAPI()); } else { callback = APICallback; //Authenticate("*****@*****.**", "test", "Kollect"); } if (apiService.IsAuthenticated) { GetGameParameters(Game.ToLower(), "warmup"); } }