Пример #1
0
        protected async Task <bool> PreCall(string serviceMd5Sum)
        {
            if (disposed)
            {
                throw new ObjectDisposedException("ServiceClient instance was disposed");
            }

            if (serviceMd5Sum != md5sum)
            {
                throw new Exception($"Call to service '{serviceName}' with md5sum '{serviceMd5Sum}' does not match the md5sum that was specified when the handle was created ('{md5sum}').");
            }

            if (serverLink != null && !serverLink.IsValid)
            {
                if (persistent)
                {
                    logger.LogWarning("Persistent service client's server link has been dropped. Trying to reconnect to proceed with this call.");
                }
                ServiceManager.Instance.RemoveServiceServerLinkAsync(serverLink);
                serverLink.Dispose();
                serverLink = null;
            }

            if (serverLink == null)
            {
                serverLink = await CreateLink();
            }

            return(true);
        }
Пример #2
0
 protected async Task Init()
 {
     if (persistent)
     {
         serverLink = await CreateLink();
     }
 }
Пример #3
0
        internal void RemoveServiceServerLinkAsync(IServiceServerLinkAsync link)
        {
            lock (gate)
            {
                if (shuttingDown)
                {
                    return;
                }

                serviceServerLinksAsync.Remove(link);
            }
        }
Пример #4
0
        public void Dispose()
        {
            if (disposed)
            {
                return;
            }
            disposed = true;

            if (serverLink != null)
            {
                ServiceManager.Instance.RemoveServiceServerLinkAsync(serverLink);
                serverLink.Dispose();
                serverLink = null;
            }
        }