Ejemplo n.º 1
0
        public async Task InitServiceConnections()
        {
            //check service connection
            IsServiceAvailable = await CheckServiceAvailable();

            if (!IsServiceAvailable)
            {
                Debug.WriteLine("Service not yet available. Waiting a few seconds..");

                // the service could still be starting up or port may be reallocated
                await Task.Delay(5000);


                // restart client in case port has reallocated
                CertifyClient = new CertifyServiceClient();

                IsServiceAvailable = await CheckServiceAvailable();

                if (!IsServiceAvailable)
                {
                    // give up
                    return;
                }
            }

            // wire up stream events
            CertifyClient.OnMessageFromService          += CertifyClient_SendMessage;
            CertifyClient.OnRequestProgressStateUpdated += UpdateRequestTrackingProgress;
            CertifyClient.OnManagedCertificateUpdated   += CertifyClient_OnManagedCertificateUpdated;

            // connect to status api stream & handle events
            await CertifyClient.ConnectStatusStreamAsync();
        }