Пример #1
0
        private void SetupNotifyHost(INotifyCallback callback)
        {
            this.m_service = new NotifyService(callback, this);
            EndpointAddress endpointAddress = new EndpointAddress("net.pipe://localhost/Microsoft.Exchange.ThirdPartyReplication.NotifyService");

            this.m_notifyHost = new ServiceHost(this.m_service, new Uri[]
            {
                endpointAddress.Uri
            });
            NetNamedPipeBinding netNamedPipeBinding = new NetNamedPipeBinding();

            netNamedPipeBinding.OpenTimeout    = this.OpenTimeout;
            netNamedPipeBinding.SendTimeout    = this.SendTimeout;
            netNamedPipeBinding.ReceiveTimeout = this.ReceiveTimeout;
            try
            {
                this.m_notifyHost.AddServiceEndpoint(typeof(IInternalNotify), netNamedPipeBinding, string.Empty);
                this.m_notifyHost.Open();
            }
            catch (CommunicationException ex)
            {
                this.m_notifyHost.Abort();
                this.m_notifyHost = null;
                throw ex;
            }
        }
Пример #2
0
        public static NotificationListener Start(INotifyCallback callback, TimeSpan retryDelay, TimeSpan openTimeout, TimeSpan sendTimeout, TimeSpan receiveTimeout)
        {
            Exception ex = null;

            ExTraceGlobals.ThirdPartyClientTracer.TraceDebug(0L, "NotificationListener is starting.");
            NotificationListener notificationListener = new NotificationListener();

            try
            {
                notificationListener.m_retryDelay     = retryDelay;
                notificationListener.m_openTimeout    = openTimeout;
                notificationListener.m_sendTimeout    = sendTimeout;
                notificationListener.m_receiveTimeout = receiveTimeout;
                notificationListener.SetupNotifyHost(callback);
                ReplayCrimsonEvents.TPRNotificationListenerStarted.Log();
                ExTraceGlobals.ThirdPartyClientTracer.TraceDebug(0L, "NotificationListener was started successfully.");
                notificationListener.SendTimeouts();
                return(notificationListener);
            }
            catch (CommunicationException ex2)
            {
                ex = ex2;
            }
            catch (Exception ex3)
            {
                ex = ex3;
            }
            if (ex != null)
            {
                ReplayCrimsonEvents.TPRNotificationListenerFailedToStart.Log <string>(ex.Message);
                ExTraceGlobals.ThirdPartyClientTracer.TraceError <Exception>(0L, "NotificationListener failed to start: {0}", ex);
                throw ex;
            }
            return(null);
        }
Пример #3
0
 public static Client Create(Guid instanceId, INotifyCallback caller)
 {
     return(new Client()
     {
         Id = instanceId,
         Callback = caller,
         IsValid = true
     });
 }
Пример #4
0
        public void Register(Guid instanceId)
        {
            Logger.WriteToLog(String.Format("Registering new client with GUID: '{0}'.", instanceId));
            INotifyCallback caller = OperationContext.Current.GetCallbackChannel <INotifyCallback>();

            if (caller != null)
            {
                bool result = _clients.TryAdd(instanceId, Client.Create(instanceId, caller));
                if (!result)
                {
                    Logger.WriteToLog(String.Format("Unable to register new client with GUID: '{0}'.", instanceId));
                }
            }
        }
Пример #5
0
 public NotifyService(INotifyCallback callback, NotificationListener listener)
 {
     this.m_callback = callback;
     this.m_listener = listener;
 }