示例#1
0
 private void DisposeDuplexChannel()
 {
     if (DuplexChannel == null)
     {
         return;
     }
     try
     {
         if (DuplexChannel.State != CommunicationState.Faulted)
         {
             DuplexChannel.Close();
         }
         else
         {
             DuplexChannel.Abort();
         }
     }
     catch (CommunicationException)
     {
         DuplexChannel.Abort();
     }
     catch (TimeoutException)
     {
         DuplexChannel.Abort();
     }
     catch (Exception)
     {
         DuplexChannel.Abort();
     }
     finally
     {
         DuplexChannel = null;
     }
 }
示例#2
0
 /// <summary>
 /// create a virtual proxy and return implementation of the service class.
 /// provide the instance context for the callback function
 /// </summary>
 /// <param name="callBack"></param>
 /// <returns></returns>
 public bool ConnectWithBinding(object callBack)
 {
     _createDuplexChannelHandler = (callback) => ConnectWithBinding(callBack);
     try
     {
         DuplexChannel = new CustomDuplexClientChannel <T>(Binding, EndpointAddress);
         RegisterToEvents();
         ClientProxy = DuplexChannel.CreateDuplexClient(callBack);
         return(true);
     }
     catch (Exception e)
     {
         Logger.LogException($"error creating Channel: {e.Message}", e, LogEnum);
         return(false);
     }
 }
示例#3
0
        private void InitDuplexFromConfigurationFile(object callbacks)
        {
            try
            {
                DuplexChannel =
                    new CustomDuplexClientChannel <T>(EndpointConfigurationName, ClientConfigFile, EndpointAddress);
                RegisterToEvents();

                if (CreateDuplexChannel(callbacks))
                {
                    Logger.LogInformation($"(init): SOA services duplex Client Initiated (BaseClient.ctor())", LogEnum);
                }
            }
            catch (Exception ex)
            {
                string error = $"Error init: SOA services duplex Client failed to send init completed:{ex.Message}";
                Logger.LogException(error, ex, LogEnum);
                throw;
            }

            _createDuplexChannelHandler = CreateDuplexChannel;
        }