Launch eye tribe server from application

Forum for C#/Windows development

Launch eye tribe server from application

Postby sreedev » 14 Apr 2015, 14:49

Hello,
I started out with the calibration example provided at Github. But it seems that I need to launch the eye tribe server application separately before my application can make use of the eye tracker. Is there any way of launching the server from my application?

Thanks.
sreedev
 
Posts: 4
Joined: 07 Feb 2015, 06:44

Re: Launch eye tribe server from application

Postby Martin » 14 Apr 2015, 16:02

Certainly possible. Here's one way of doing it.

First, we determine if the server is running already

Code: Select all
        private static bool IsServerProcessRunning()
        {
            try
            {
                foreach(Process p in Process.GetProcesses())
                {
                    if(p.ProcessName.ToLower() == "eyetribe")
                        return true;
                }
            }
            catch (Exception)
            { }

            return false;
        }


If the server is not running we locate the executable by the method GetServerExecutablePath() and then start it:

Code: Select all
        private static void StartServerProcess()
        {
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.WindowStyle = ProcessWindowStyle.Minimized;
            psi.FileName = GetServerExecutablePath();

            if (psi.FileName == string.Empty || File.Exists(psi.FileName) == false)
                return;

            Process processServer = new Process();
            processServer.StartInfo = psi;
            processServer.Start();

            Thread.Sleep(3000); // wait for it to spin up
        }


Code: Select all
        private static string GetServerExecutablePath()
        {
            // check default paths           
            const string x86 = "C:\\Program Files (x86)\\EyeTribe\\Server\\EyeTribe.exe";
            if (File.Exists(x86))
                return x86;               

            const string x64 = "C:\\Program Files\\EyeTribe\\Server\\EyeTribe.exe";
            if (File.Exists(x64))
                return x64;

            // Still not found, let user select file
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.DefaultExt = ".exe";
            dlg.Title = "Please select the Eye Tribe server executable";
            dlg.Filter = "Executable Files (*.exe)|*.exe";

            if (dlg.ShowDialog() == true)
                return dlg.FileName;

            return string.Empty;
        }



Hope this helps ;)
Martin
 
Posts: 567
Joined: 29 Oct 2013, 15:20

Re: Launch eye tribe server from application

Postby sreedev » 14 Apr 2015, 18:29

I haven't tried the code yet. But it seems to me that what you suggested launches the already installed server. What I am actually looking for is not to launch the already existing server but to have it within my application and run in background without the command line window popping up.
sreedev
 
Posts: 4
Joined: 07 Feb 2015, 06:44

Re: Launch eye tribe server from application

Postby Martin » 15 Apr 2015, 00:22

No can do, it's not a DLL. It needs to run as it's own process (for many reasons). Perhaps minimize the application window programmatically?

What are you trying to accomplish?
Martin
 
Posts: 567
Joined: 29 Oct 2013, 15:20

Re: Launch eye tribe server from application

Postby sreedev » 15 Apr 2015, 20:37

Thanks for your reply. I solved the issue by setting the window style to hidden.
sreedev
 
Posts: 4
Joined: 07 Feb 2015, 06:44


Return to C#



cron