Ejemplo n.º 1
0
        /// <summary>
        /// Get client channel remote status
        /// </summary>
        /// <param name="channelId"></param>
        /// <returns></returns>
        public async Task <bool?> GetChannelRemoteStatusValue(string channelId)
        {
            // status service not supported
            if (_statusService == null)
            {
                GetChannelInvoker(channelId).SetAplOnline();
                return(await Task.FromResult <bool?>(null));
            }

            // make remote call
            bool remoteStatus = false;

            using (var store = new CancellationTokenSource())
            {
                try
                {
                    store.CancelAfter(5000);
                    var status = await _statusService.CheckStatus(new CheckStatusRequest { ChannelId = channelId }, store.Token);

                    remoteStatus = status?.Status ?? false;
                }
                catch (Exception)
                {
                }
            }

            // set online/offline status
            if (remoteStatus)
            {
                GetChannelInvoker(channelId).SetAplOnline();
            }
            else
            {
                GetChannelInvoker(channelId).SetAplOffline();
            }

            // return
            return(remoteStatus);
        }