Skip to content

Commit

Permalink
Gazepoint connection attempt is now limited to 5 seconds
Browse files Browse the repository at this point in the history
GazepointTracker was previously freezing core if a Gazepoint device was not connected. It is now limited to attempting to connect for 5 seconds, similar to SmartEyeTracker.
  • Loading branch information
fisherdog1 committed May 16, 2022
1 parent 80e1d76 commit 780eb5d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions itrace_core/GazePointTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ public GazePointTracker()
try
{
Client = new System.Net.Sockets.TcpClient();
IAsyncResult conn = Client.BeginConnect(GAZEPOINT_ADDRESS, GAZEPOINT_PORT, null, null);

bool asyncConnectSuccess = conn.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(5));

if (!asyncConnectSuccess)
throw new Exception("Gazepoint timed out while connecting (Most likely there is no Gazepoint device available)");

Client.Connect(GAZEPOINT_ADDRESS, GAZEPOINT_PORT);
Reader = new System.IO.StreamReader(Client.GetStream());
Writer = new System.IO.StreamWriter(Client.GetStream());
Expand Down

0 comments on commit 780eb5d

Please sign in to comment.