Exemplo n.º 1
0
        /// <summary>
        /// Remove a {@link TETCSharpClient.IGazeListener} from the TET C# client.
        /// </summary>
        /// <returns>True if succesfully removed, false otherwise</returns>
        /// <param name="listener"/>The {@link TETCSharpClient.IGazeListener} instance to remove</param>
        public bool RemoveGazeListener(IGazeListener listener)
        {
            bool result = false;

            lock (((ICollection)gazeListeners).SyncRoot)
            {
                if (gazeListeners.Contains(listener))
                {
                    result = gazeListeners.Remove(listener);
                }

                if (gazeListeners.Count == 0)
                {
                    if (null != gazeBroadcaster)
                    {
                        gazeBroadcaster.Stop();
                        gazeBroadcaster = null;
                    }

                    lock (((ICollection)queueGazeData).SyncRoot)
                    {
                        queueGazeData.Clear();
                    }
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Clear all attached listeners, clears GazeData queue and stop broadcating
        /// </summary>
        public void ClearListeners()
        {
            lock (((ICollection)gazeListeners).SyncRoot)
            {
                gazeListeners.Clear();
            }

            lock (((ICollection)calibrationStateListeners).SyncRoot)
            {
                calibrationStateListeners.Clear();
            }

            lock (((ICollection)trackerStateListeners).SyncRoot)
            {
                trackerStateListeners.Clear();
            }

            lock (((ICollection)queueGazeData).SyncRoot)
            {
                queueGazeData.Clear();
            }

            if (null != gazeBroadcaster)
            {
                gazeBroadcaster.Stop();
                gazeBroadcaster = null;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a {@link TETCSharpClient.IGazeListener} to the TET C# client. This listener
        /// will recieve {@link TETCSharpClient.Data.GazeData} updates when available
        /// </summary>
        /// <param name="listener"/>The {@link TETCSharpClient.IGazeListener} instance to add</param>
        public void AddGazeListener(IGazeListener listener)
        {
            if (null != listener)
            {
                lock (((ICollection)gazeListeners).SyncRoot)
                {
                    if (gazeListeners.Count == 0)
                    {
                        //init wait handles
                        events = new WaitHandleWrap();

                        //init broadcasting routines,
                        gazeBroadcaster = new GazeBroadcaster(queueGazeData, gazeListeners, events);
                        gazeBroadcaster.Start();
                    }

                    if (!gazeListeners.Contains(listener))
                    {
                        gazeListeners.Add(listener);
                    }
                }
            }
        }