Beispiel #1
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);
                    }
                }
            }
        }
        public bool Connect(string host, int port)
        {
            Close();

            try
            {
                outEvent = new WaitHandleWrap();
                socket   = new TcpClient(host, port);

                incomingStreamHandler = new IncomingStreamHandler(socket, responseListener);
                incomingStreamHandler.Start();

                outgoingStreamHandler = new OutgoingStreamHandler(socket, requestQueue, outEvent);
                outgoingStreamHandler.Start();
            }
            catch (Exception e)
            {
                Debug.WriteLine("Error opening socket. Is Tracker Server running? " + e.Message);
                Close();
                return(false);
            }
            return(true);
        }
        public bool Connect(string host, int port)
        {
            Close();

            try
            {
                outEvent = new WaitHandleWrap();
                socket = new TcpClient(host, port);

                incomingStreamHandler = new IncomingStreamHandler(socket, responseListener);
                incomingStreamHandler.Start();

                outgoingStreamHandler = new OutgoingStreamHandler(socket, requestQueue, outEvent);
                outgoingStreamHandler.Start();
            }
            catch (Exception e)
            {
                Debug.WriteLine("Error opening socket. Is Tracker Server running? " + e.Message);
                Close();
                return false;
            }
            return true;
        }
 public OutgoingStreamHandler(TcpClient socket, Queue<String> queue, WaitHandleWrap events)
 {
     this.socket = socket;
     this.queue = queue;
     this.events = events;
 }
        /// <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);
                }
            }
        }
 public OutgoingStreamHandler(TcpClient socket, Queue <String> queue, WaitHandleWrap events)
 {
     this.socket = socket;
     this.queue  = queue;
     this.events = events;
 }
Beispiel #7
0
 public GazeBroadcaster(FixedSizeQueue <GazeData> queue, List <IGazeListener> gazeListeners, WaitHandleWrap events)
 {
     this.gazeListeners = gazeListeners;
     this.queue         = queue;
     this.events        = events;
 }