/// <summary>
        /// Login with device id. A user registered with this method is called a headless account because it doesn't
        /// have username yet.
        /// </summary>
        /// <param name="callback">Returns Result via callback when completed</param>
        public void LoginWithDeviceId(ResultCallback callback)
        {
            DeviceProvider deviceProvider = DeviceProvider.GetFromSystemInfo();

            this.taskDispatcher.Start(
                Task.Retry(
                    cb => this.LoginWithDeviceIdAsync(deviceProvider, result => cb(result)),
                    result => this.coroutineRunner.Run(() => callback((Result)result)),
                    null));
        }
        public IEnumerator LoginWithDeviceId(ResultCallback callback)
        {
            Report.GetFunctionLog(this.GetType().Name);
            DeviceProvider deviceProvider = DeviceProvider.GetFromSystemInfo();

            IHttpRequest request = HttpRequestBuilder.CreatePost(this.baseUrl + "/v1/login/platforms/{platformId}")
                                   .WithPathParam("platformId", deviceProvider.DeviceType)
                                   .WithBasicAuth(this.clientId, this.clientSecret)
                                   .WithContentType(MediaType.ApplicationForm)
                                   .Accepts(MediaType.ApplicationJson)
                                   .WithFormParam("device_id", deviceProvider.DeviceId)
                                   .WithFormParam("namespace", this.@namespace)
                                   .GetResult();

            IHttpResponse response = null;

            yield return(this.httpWorker.SendRequest(request, rsp => response = rsp));

            TrySetAccessToken(callback, response);
        }
Exemplo n.º 3
0
        public TelemetryApi(string baseUrl)
        {
            this.baseUrl = baseUrl;

            switch (Application.platform)
            {
            case RuntimePlatform.WindowsPlayer:
                this.agentType = 70;
                break;

            case RuntimePlatform.OSXPlayer:
                this.agentType = 80;
                break;

            case RuntimePlatform.LinuxPlayer:
                this.agentType = 90;
                break;

            case RuntimePlatform.Android:
                this.agentType = 110;
                break;

            case RuntimePlatform.IPhonePlayer:
                this.agentType = 120;
                break;

            case RuntimePlatform.XboxOne:
                this.agentType = 130;
                break;

            case RuntimePlatform.PS4:
                this.agentType = 140;
                break;

            case RuntimePlatform.Switch:
                this.agentType = 170;
                break;

            case RuntimePlatform.tvOS:
                this.agentType = 200;
                break;

            case RuntimePlatform.WSAPlayerX86:
                this.agentType = 210;
                break;

            case RuntimePlatform.WSAPlayerX64:
                this.agentType = 211;
                break;

            case RuntimePlatform.WSAPlayerARM:
                this.agentType = 212;
                break;

            case RuntimePlatform.WebGLPlayer:
                this.agentType = 220;
                break;
            }

            this.deviceId = DeviceProvider.GetFromSystemInfo().DeviceId;
        }
        public TelemetryApi(string baseUrl, IHttpWorker httpWorker)
        {
            Report.GetFunctionLog(this.GetType().Name);
            Assert.IsNotNull(baseUrl, "Creating " + GetType().Name + " failed. Parameter baseUrl is null");
            Assert.IsNotNull(httpWorker, "Creating " + GetType().Name + " failed. Parameter httpWorker is null");

            this.baseUrl    = baseUrl;
            this.httpWorker = httpWorker;

            switch (Application.platform)
            {
            case RuntimePlatform.WindowsPlayer:
                this.agentType = 70;

                break;

            case RuntimePlatform.OSXPlayer:
                this.agentType = 80;

                break;

            case RuntimePlatform.LinuxPlayer:
                this.agentType = 90;

                break;

            case RuntimePlatform.Android:
                this.agentType = 110;

                break;

            case RuntimePlatform.IPhonePlayer:
                this.agentType = 120;

                break;

            case RuntimePlatform.XboxOne:
                this.agentType = 130;

                break;

            case RuntimePlatform.PS4:
                this.agentType = 140;

                break;

            case RuntimePlatform.Switch:
                this.agentType = 170;

                break;

            case RuntimePlatform.tvOS:
                this.agentType = 200;

                break;

            case RuntimePlatform.WSAPlayerX86:
                this.agentType = 210;

                break;

            case RuntimePlatform.WSAPlayerX64:
                this.agentType = 211;

                break;

            case RuntimePlatform.WSAPlayerARM:
                this.agentType = 212;

                break;

            case RuntimePlatform.WebGLPlayer:
                this.agentType = 220;

                break;
            }

            this.deviceId = DeviceProvider.GetFromSystemInfo().DeviceId;
        }