Пример #1
0
 public bool Connect(Guid appId,string uriPath)
 {
     _currentAppId = appId;
     try
     {
         NetTcpBinding binding = new NetTcpBinding { Security = { Mode = SecurityMode.None, Transport = { ClientCredentialType = TcpClientCredentialType.None } } };
         _notifierServiceFactory = new DuplexChannelFactory<INotifierService>(new InstanceContext(this), binding, new EndpointAddress(uriPath));
         _notifierServiceProxy = _notifierServiceFactory.CreateChannel();
         _notifierServiceFactory.Faulted += (_, __) =>
         {
             Disconnect(false);
             OnExceptionInService(null, true);
         };
         Connected=_notifierServiceProxy.Subscribe(_currentAppId);
         return Connected;
     }
     catch (Exception ex)
     {
         Disconnect(false);
         OnExceptionInService(ex,true);
         //throw;
     }
     return false;
 }