GazeCoordinateBehavior.cs 896 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10
using System;
using WebSocketSharp;
using WebSocketSharp.Server;
using System.Collections.Generic;
using System.Text;

namespace GazeWebSocketServer
{
    public class GazeCoordinateBehavior : WebSocketBehavior
    {
11 12
        private EyeTrackerClient eyeTrackerClient;

13
        public GazeCoordinateBehavior(ConfigurationData config)
14 15
        {
            Console.WriteLine("Creating behavior...");
16
            eyeTrackerClient = new EyeTrackerClient(config);
17 18 19
            eyeTrackerClient.Start(this);
        }

20 21 22 23
        //~GazeCoordinateBehavior()
        //{
        //    eyeTrackerClient.Stop();
        //}
24 25 26 27 28 29 30 31

        //protected override void OnOpen()
        //{
        //    throw new NotImplementedException();
        //    //base.OnOpen();
        //}

        internal void Publish(GazeData gazeData)
32
        {
33
            Sessions?.Broadcast(gazeData.ToString());
34 35 36
        }
    }
}