using System; using TrackerBridge; namespace GazeWebSocketServer { public class Program { private static GazeServer gazeServer; public static void Main(string[] args) { ConfigurationData.InitializeUnexistingWithDefaults(); ConfigurationData config = ConfigurationData.ParseToObject(); IBridgeTracker tracker; if (args.Length > 0 && args[0] == "-d") { tracker = new FakeTracker(600); } else { tracker = new TobiiEyeTracker(config.TrackerSerialNumber); } tracker.ConnectionEvent += OnConnectionEstablished; tracker.ConnectionTimeout += OnConnectionTimeout; tracker.GazeDataAvailable += OnGazeDataAvailable; tracker.Connect(); gazeServer = new GazeServer(config.WebSocketPort, config.WebSocketEndpoint); gazeServer.Start(); Console.ReadLine(); } private static void OnGazeDataAvailable(GazeData data, Object sender) { if (gazeServer != null && gazeServer.isRunning) { gazeServer.Publish(data); } } private static void OnConnectionTimeout(IBridgeTracker sender) { Console.WriteLine("Timeout while searching for trackers."); } private static void OnConnectionEstablished(IBridgeTracker sender) { Console.WriteLine($"Tracker {sender.SerialNumber} connected."); ConfigurationData config = ConfigurationData.ParseToObject(); sender.TrackingFrequency = config.TrackerFrequency; sender.OutputFrequency = config.OutputFrequency; } } }