Пример #1
0
		public EnhancedPresence1(NotifyEventHandler notifyEvent)
		{
			this.notifyEvent = notifyEvent;

			Subscription.ResolvePublicationEvent += ResolvePublication;
			SubscriptionResource.NotifySubscriberEvent += SubscriptionResource_NotifySubscriber;

			this.timer = new Timer(new TimerCallback(ValidateExpired), null, 1000, 1000);
		}
		public void AddNotify (string dir, NotifyEventHandler notify)
		{
			if (dir == null)
				throw new NullReferenceException("dir");
			if (notify == null)
				throw new NullReferenceException("notify");

			NotifyWrapper wrapper = new NotifyWrapper (notify, dir);
			client.AddNotify (dir, wrapper.HandleNotify);
			wrapper_list.Add (wrapper);
		}
 internal TcpSocketSaeaSession(
     NotifyEventHandler <TcpSessionNotify, TcpSocketSaeaSession> notifyEventHandler,
     TcpSocketConfigurationBase configuration,
     SaeaAwaiterPool handlerSaeaPool,
     SessionPool sessionPool,
     TcpSocketSaeaEngineBased agent)
 {
     NotifyEventHandler = notifyEventHandler;
     Configuration      = configuration;
     HandlerSaeaPool    = handlerSaeaPool;
     SessionPools       = sessionPool;
     Agent = agent;
 }
 internal TcpSocketSaeaClientAgent(
     TcpSocketSaeaSessionType saeaSessionType,
     TcpSocketSaeaClientConfiguration configuration,
     NotifyEventHandler <TcpSocketCompletionNotify, TcpSocketSaeaSession> completetionNotify)
     : base(saeaSessionType, configuration, completetionNotify)
 {
     if (configuration.AppKeepAlive &&
         saeaSessionType == TcpSocketSaeaSessionType.Packet)
     {
         var keepAliveThread = new Thread(AppKeepAliveWorkThread);
         keepAliveThread.IsBackground = true;
         keepAliveThread.Start();
     }
 }
Пример #5
0
 /// <summary>
 /// This method is invoked by the parent when a new instance is constructed,
 /// and this must copy all current state to this instance from the argument.
 /// </summary>
 /// <param name="notifyEventHandler">Not null.</param>
 public virtual void CopyStateFrom(NotifyEventHandler notifyEventHandler)
 {
     if (notifyEventHandler == null)
     {
         throw new ArgumentNullException(nameof(notifyEventHandler));
     }
     collectionChangedEventArgs = notifyEventHandler.collectionChangedEventArgs;
     raiseCount           = notifyEventHandler.raiseCount;
     raiseIndexer         = notifyEventHandler.raiseIndexer;
     raisePropertyChanged = notifyEventHandler.raisePropertyChanged.IsNullOrEmpty()
                                     ? null
                                     : new List <string>(notifyEventHandler.raisePropertyChanged);
     IsSuspended = notifyEventHandler.IsSuspended;
     IsRaiseAllEventsAsResetEvents = notifyEventHandler.IsRaiseAllEventsAsResetEvents;
 }
Пример #6
0
        /// <summary>
        /// 触发事件函数
        /// </summary>
        /// <param name="args"></param>
        protected virtual void OnDataRecived(DataNotifyEventArgs args)
        {
            var delegateHandles = NotifyEventHandler.GetInvocationList();

            foreach (Delegate item in delegateHandles)
            {
                try
                {
                    item.DynamicInvoke(this, args);
                }
                catch
                {
                }
            }
        }
Пример #7
0
 internal TcpSocketSaeaSession(
     NotifyEventHandler <TcpSocketCompletionNotify, TcpSocketSaeaSession> notifyEventHandler,
     TcpSocketConfigurationBase configuration,
     SaeaAwaiterPool handlerSaeaPool,
     SessionPool sessionPool,
     TcpSocketSaeaEngineBased agent,
     LogHelper logHelper)
 {
     _notifyEventHandler = notifyEventHandler;
     _configuration      = configuration;
     _handlerSaeaPool    = handlerSaeaPool;
     _sessionPool        = sessionPool;
     _agent  = agent;
     _logger = logHelper;
 }
Пример #8
0
        public void AddNotify(string dir, NotifyEventHandler notify)
        {
            if (dir == null)
            {
                throw new NullReferenceException("dir");
            }
            if (notify == null)
            {
                throw new NullReferenceException("notify");
            }

            NotifyWrapper wrapper = new NotifyWrapper(notify, dir);

            client.AddNotify(dir, wrapper.HandleNotify);
            wrapper_list.Add(wrapper);
        }
Пример #9
0
        internal TcpSocketSaeaEngineBased(
            TcpSocketSaeaSessionType saeaSessionType,
            TcpSocketConfigurationBase configuration,
            NotifyEventHandler <TcpSessionNotify, TcpSocketSaeaSession> completetionNotify)
        {
            TcpSocketSaeaSessions = new List <TcpSocketSaeaSession>();
            HandlerSaeaPool       = new SaeaAwaiterPool();
            SessionPool           = new SessionPool();

            SaeaSessionType    = saeaSessionType;
            Configuration      = configuration;
            CompletetionNotify = completetionNotify;

            HandlerSaeaPool.Initialize(() => new SaeaAwaiter(),
                                       (saea) =>
            {
                try
                {
                    saea.Saea.AcceptSocket = null;
                    saea.Saea.SetBuffer(EmptyArray, 0, EmptyArray.Length);
                    saea.Saea.RemoteEndPoint = null;
                    saea.Saea.SocketFlags    = SocketFlags.None;
                }
                catch (Exception ex)
                {
                    Console.WriteLine("server_clean awaiter info:" + ex.Message);
                }
            },
                                       50);
            if (saeaSessionType == TcpSocketSaeaSessionType.Full)
            {
                SessionPool.Initialize(() => new TcpSocketSaeaFullBased(Configuration, HandlerSaeaPool, SessionPool, completetionNotify, this),
                                       (session) =>
                {
                    session.Detach();
                }, 50);
            }
            else
            {
                SessionPool.Initialize(() => new TcpSocketSaeaPackBased(Configuration, HandlerSaeaPool, SessionPool, completetionNotify, this),
                                       (session) =>
                {
                    session.Detach();
                }, 50);
            }
        }
Пример #10
0
            public void Remove(NotifyEventHandler notify)
            {
                ArrayList removes = new ArrayList();

                foreach (uint id in connections.Keys)
                {
                    if (connections [id] == notify)
                    {
                        removes.Add(id);
                    }
                }
                foreach (uint id in removes)
                {
                    gconf_client_notify_remove(handle, id);
                    connections.Remove(id);
                }
            }
Пример #11
0
 public void Set(string key, object value)
 {
     try {
         CreatePath(key);
         prefsDoc.SelectSingleNode(key).InnerText = System.Convert.ToString(value);
         prefsDoc.Save(fileName);
         foreach (string nkey in events.Keys)
         {
             NotifyEventHandler handler = events [nkey] as NotifyEventHandler;
             if (handler != null && key.StartsWith(nkey))
             {
                 NotifyEventArgs args = new NotifyEventArgs(key, value);
                 handler(this, args);
             }
         }
     }
     catch {}
 }
Пример #12
0
 /// <summary>
 /// 订阅数据
 /// </summary>
 /// <param name="name"></param>
 /// <param name="notifyEvent"></param>
 public static void Subscribe(string name, NotifyEventHandler notifyEvent)
 {
     //必须方法同步
     lock (lock_obj)
     {
         Topic subscriber = null;
         if (topic.TryGetValue(name, out subscriber))
         {
             subscriber.AddObserver(notifyEvent);
         }
         else
         {
             //说明是先订阅
             subscriber = new Topic(name, null);
             subscriber.AddObserver(notifyEvent);
             topic[name] = subscriber;
         }
     }
 }
        private void PacketPartProcess(SaeaAwaiter awaiter, SocketError error)
        {
            var bytesTransferred = awaiter.Saea.BytesTransferred;

            if (bytesTransferred == 0 ||
                error != SocketError.Success ||
                State != TcpSocketConnectionState.Connected ||
                Socket == null)
            {
                LogHelper.WriteLog("session_recv endtransfer state:" + State.ToString() + " socket_error:" + error.ToString());
                this.EndTransfer(awaiter);
                return;
            }
            this.ReceiveBytesTransferred = bytesTransferred;

            NotifyEventHandler?.Invoke(TcpSessionNotify.OnDataReceiveing, this);

            awaiter.Saea.SetBuffer(CompletedBuffer, 0, CompletedBuffer.Length);
            SaeaExHelper.ReceiveAsync(this.Socket, awaiter, PacketPartProcess);
        }
 public static Task<string> GetAsync()
 {
     var t = new TaskCompletionSource<string>();
     var w = new WebView();
     w.AllowedScriptNotifyUris = WebView.AnyScriptNotifyUri;
     w.NavigateToString("<html />");
     NotifyEventHandler h = null;
     h = (s, e) =>
     {
         try
         {
             var match = Regex.Match(e.Value, @"Windows\s+NT\s+\d+(\.\d+)?");
             if (match.Success)
                 t.SetResult(match.Value);
             else
                 t.SetResult("Unknowm");
         }
         catch (Exception ex) { t.SetException(ex); }
         finally { /* release */ w.ScriptNotify -= h; }
     };
     w.ScriptNotify += h;
     w.InvokeScript("execScript", new[] { "window.external.notify(navigator.appVersion); " });
     return t.Task;
 }
		public void RemoveNotify (string dir, NotifyEventHandler notify)
		{
			if (dir == null)
				throw new NullReferenceException("dir");
			if (notify == null)
				throw new NullReferenceException("notify");

			NotifyWrapper wrapper_to_remove = null;
			foreach (NotifyWrapper wrapper in wrapper_list)
				if (wrapper.dir.Equals (dir) && wrapper.notify.Equals (notify)) {
					wrapper_to_remove = wrapper;
					break;
				}

			// NOTE: For some unknown reason, the RemoveNotify call does not
			//		 work here.  That is why we explicitly disable the wrapper,
			//		 since it will unfortunately continue to exist and get
			//		 inappropriately notified.
			if (wrapper_to_remove != null) {
				client.RemoveNotify (dir, wrapper_to_remove.HandleNotify);
				wrapper_to_remove.enabled = false;
				wrapper_list.Remove (wrapper_to_remove);
			}
		}
Пример #16
0
		public void RemoveNotify (string dir, NotifyEventHandler notify)
		{
			lock (events) {
				if (events.ContainsKey (dir))
					events [dir] -= notify;
			}
		}
Пример #17
0
		public void RemoveNotify (string dir, NotifyEventHandler notify)
		{
			// Do nothing
		}
Пример #18
0
 public static void AddObserver(NotifyEventHandler ob) {
     NotifyEvent += ob;
   
 }
Пример #19
0
 public void AddNotify(string dir, NotifyEventHandler notify)
 {
     GetConnections(dir).Add(notify);
 }
 protected virtual void ProcessNotifyEvent(NotifyEventHandler handler, NotifyEventArgs args)
 {
     if (handler != null)
     {
         handler(this, args);
     }
 }
Пример #21
0
        public static void Notify(INotification notification)
        {
            notifications.Add(notification);

            if (notified == null)
                notified = new NotifyEventHandler(notifHandler);
            notified(null, new NotifyEventArgs(notification));
        }
Пример #22
0
 public static UnmanagedEventHandler CreateNotifyEventHandlerDispatcher(NotifyEventHandler handler)
 {
     return(SafeDispatcher((sender, calldata, closure)
                           => handler(NativeDependencyObjectHelper.FromIntPtr(closure),
                                      new NotifyEventArgs())));
 }
Пример #23
0
Файл: Conf.cs Проект: GNOME/blam
        public static void AddNotify(string baseDir, NotifyEventHandler handler)
        {
            EnsureClient ();

            GConfClient.AddNotify (baseDir, handler);
        }
Пример #24
0
 public void AddObserver(NotifyEventHandler ob) => NotifyEvent    += ob; //增加订阅消息
Пример #25
0
 public void AddListener(string path, NotifyEventHandler handler)
 {
     client.AddNotify(path, handler);
 }
Пример #26
0
 public void RemoveNotify(string dir, NotifyEventHandler notify)
 {
     // Do nothing
 }
Пример #27
0
 /// <summary>
 /// 移除订阅人员
 /// </summary>
 /// <param name="obj"></param>
 public void RemoveObserver(NotifyEventHandler obj)
 {
     NotifyEvent -= obj;
 }
Пример #28
0
 public static void AddObserver(NotifyEventHandler ob)
 {
     NotifyEvent += ob;
 }
Пример #29
0
 public static void RemoveObserver(NotifyEventHandler ob) {
     NotifyEvent -= ob;
 }
Пример #30
0
 public void RemoveObserver(NotifyEventHandler notdel)
 {
     mydel -= notdel;
 }
		public NotifyWrapper (NotifyEventHandler notify)
		{
			this.notify = notify;
			this.native = new NotifyFuncNative (this.NotifyCB);
		}
Пример #32
0
 public NotifyWrapper(NotifyEventHandler notify)
 {
     this.notify = notify;
     this.native = new NotifyFuncNative(this.NotifyCB);
 }
		public static NotifyFuncNative Wrap (NotifyEventHandler notify)
		{
			NotifyWrapper wrapper = new NotifyWrapper (notify);
			refs.Add (wrapper);
			return wrapper.native;
		}
			public NotifyWrapper (NotifyEventHandler notify, string dir)
			{
				this.notify = notify;
				this.dir = dir;
			}
Пример #35
0
		public static UnmanagedEventHandler CreateNotifyEventHandlerDispatcher (NotifyEventHandler handler)
		{
			return SafeDispatcher( (sender, calldata, closure)
						=> handler (NativeDependencyObjectHelper.FromIntPtr (closure),
								new NotifyEventArgs ()) );
		}
Пример #36
0
 public void RemoveNotify(string dir, NotifyEventHandler notify)
 {
     GetConnections(dir).Remove(notify);
 }
Пример #37
0
			public void Add (NotifyEventHandler notify)
			{
				IntPtr error;
				uint id = gconf_client_notify_add (handle, path, NotifyWrapper.Wrap (notify), IntPtr.Zero, IntPtr.Zero, out error);
				if (error != IntPtr.Zero)
					throw new GLib.GException (error);

				connections [id] = notify;
			}
Пример #38
0
 public void Detach(NotifyEventHandler obj)
 {
     NotifyEvent -= obj;
 }
Пример #39
0
		public void AddNotify (string dir, NotifyEventHandler notify)
		{
			GetConnections (dir).Add (notify);
		}
Пример #40
0
		public void AddNotify (string dir, NotifyEventHandler notify)
		{
			lock (events) {
				if (!events.ContainsKey (dir))
					events [dir] = notify;
				else
					events [dir] += notify;
			}
		}
Пример #41
0
    public static void AddNotify(NotifyEventHandler handler)
    {
        EnsureClient ();

        GConfClient.AddNotify (GConfBase, handler);
    }
Пример #42
0
 public void Attach(NotifyEventHandler obj)
 {
     NotifyEvent += obj;
 }
Пример #43
0
 public void AddListener(string path, NotifyEventHandler handler)
 {
     client.AddNotify (path, handler);
 }
Пример #44
0
			public void Remove (NotifyEventHandler notify)
			{
				ArrayList removes = new ArrayList ();
				foreach (uint id in connections.Keys)
					if (connections [id] == notify)
						removes.Add (id);
				foreach (uint id in removes) {
					gconf_client_notify_remove (handle, id);
					connections.Remove (id);
				}
			}
Пример #45
0
 public NotifyWrapper(NotifyEventHandler notify, string dir)
 {
     this.notify = notify;
     this.dir    = dir;
 }
Пример #46
0
		public void RemoveNotify (string dir, NotifyEventHandler notify)
		{
			GetConnections (dir).Remove (notify);
		}
Пример #47
0
 public void AddObserver(NotifyEventHandler observer)
 {
     NotifyEvent += observer;
 }
Пример #48
0
 /// <summary>
 /// 取消绑定订阅
 /// </summary>
 /// <param name="observer"></param>
 public void RemoteObserver(NotifyEventHandler observer)
 {
     NotifyEvent -= observer;
 }
Пример #49
0
 //委托实现
 public void AddObserver(NotifyEventHandler notdel)
 {
     mydel += notdel;
 }
Пример #50
0
 public static void RemoveObserver(NotifyEventHandler ob)
 {
     NotifyEvent -= ob;
 }
Пример #51
0
 public void AddObserver(NotifyEventHandler ob) => NotifyEvent    += ob; //增加订阅消息
 public void RemoveObserver(NotifyEventHandler ob) => NotifyEvent -= ob; //去除订阅消息