public bool StartNetworkKinect()
{
bool success = true;
//Parse all the settings
string name = "";
if (masterKinectSettings.serverName.Length >= 3) //By my math, 3 characters is the smallest possible valid server name
{
name = masterKinectSettings.serverName;
}
else
{
LogMessage(string.Format("The network Kinect server name of Kinect {0} is invalid.", kinectID), false);
success = false;
}
//Parse the hand settings. Hand servers aren't required, so if they don't exist, we will pass a null name and the button server just won't be started for it.
if (masterKinectSettings.rhServerName != null && masterKinectSettings.rhServerName.Length >= 3 && masterKinectSettings.rhChannel >= 0)
{
rhName = masterKinectSettings.rhServerName;
}
if (masterKinectSettings.lhServerName != null && masterKinectSettings.lhServerName.Length >= 3 && masterKinectSettings.lhChannel >= 0)
{
lhName = masterKinectSettings.lhServerName;
}
//Launch the server
if (success)
{
try
{
//Launch the VRPN client on another thread
forceStop = false;
RunNetworkKinectDelegate networkKinectDelegate = RunNetworkKinect;
networkKinectDelegate.BeginInvoke(name, rhName, lhName, null, null);
//Start the update time
updateTimer = new System.Timers.Timer();
updateTimer.AutoReset = true;
updateTimer.Interval = 10;
updateTimer.Elapsed += updateTime_Elapsed;
updateTimer.Start();
}
catch (Exception error)
{
LogMessage(string.Format("An error occured trying to start network Kinect with ID {0}. The error message is: {1}", kinectID, error.Message), false);
success = false;
isRunning = false;
}
}
return success;
}