private void ConnectClient() { bThreadRunning = true; // We have to handle the multi-route syntax, which is of the form HostName1:Port;Hostname2:Port String CombinedHostnameString = ""; String[] Hosts = HostName.Split(';'); foreach (String Host in Hosts) { String TrimmedString = Host.Trim(); String HostWithPort = null; // Check whether the hostname already contains a port and add if it doesn't if (TrimmedString.Contains(":")) { HostWithPort = TrimmedString; } else { HostWithPort = TrimmedString + ":" + Port; } if (!String.IsNullOrEmpty(CombinedHostnameString)) { CombinedHostnameString += ";"; } CombinedHostnameString += HostWithPort; } print("Connecting to " + CombinedHostnameString + "..."); if (IsRetimed) { while (bThreadRunning == true && !m_RetimingClient.IsConnected().Connected) { Output_Connect OC = m_RetimingClient.Connect(CombinedHostnameString); print("Connect result: " + OC.Result); System.Threading.Thread.Sleep(200); } if (UseLightweightData) { // Retiming client will have segment data enabled by default if (m_RetimingClient.EnableLightweightSegmentData().Result == Result.Success) { print("Using lightweight segment data"); } else { print("Unable to use lightweight segment data: Using standard segment data"); } } else { print("Using standard segment data"); } // get a frame from the data stream so we can inspect the list of subjects SetAxisMapping(Direction.Forward, Direction.Left, Direction.Up); //SetAxisMapping(Direction.Right, Direction.Up, Direction.Backward); ConnectionHandler(true); bThreadRunning = false; return; } while (bThreadRunning == true && !m_Client.IsConnected().Connected) { Output_Connect OC = m_Client.Connect(CombinedHostnameString); print("Connect result: " + OC.Result); System.Threading.Thread.Sleep(200); } if (UsePreFetch) { m_Client.SetStreamMode(StreamMode.ClientPullPreFetch); } else { m_Client.SetStreamMode(StreamMode.ServerPush); } // Get a frame first, to ensure we have received supported type data from the server before // trying to determine whether lightweight data can be used. GetNewFrame(); if (UseLightweightData) { if (m_Client.EnableLightweightSegmentData().Result != Result.Success) { print("Unable to use lightweight segment data: Using standard segment data"); m_Client.EnableSegmentData(); } else { print("Using lightweight segment data"); } } else { print("Using standard segment data"); m_Client.EnableSegmentData(); } SetAxisMapping(Direction.Forward, Direction.Left, Direction.Up); //SetAxisMapping(Direction.Right, Direction.Up, Direction.Backward); ConnectionHandler(true); // Get frames in this separate thread if we've asked for it. while (GetFrameThread && bThreadRunning) { GetNewFrame(); } bThreadRunning = false; }
private void ConnectClient() { bThreadRunning = true; String Host = HostName + ":" + Port; print("Connecting to " + Host + "..."); string res = ""; if (IsRetimed) { while (bThreadRunning == true && !m_RetimingClient.IsConnected().Connected) { Output_Connect OC = m_RetimingClient.Connect(Host); print("Connect result: " + OC.Result); System.Threading.Thread.Sleep(200); } if (UseLightweightData) { // Retiming client will have segment data enabled by default if (m_RetimingClient.EnableLightweightSegmentData().Result == Result.Success) { print("Using lightweight segment data"); } else { print("Unable to use lightweight segment data: Using standard segment data"); } } else { print("Using standard segment data"); } // get a frame from the data stream so we can inspect the list of subjects SetAxisMapping(Direction.Forward, Direction.Left, Direction.Up); //SetAxisMapping(Direction.Right, Direction.Up, Direction.Backward); ConnectionHandler(true); while (bThreadRunning == true) { print("getting new frame"); GetNewFrame(); } bThreadRunning = false; return; } while (bThreadRunning == true && !m_Client.IsConnected().Connected) { m_Client.EnableMarkerData(); m_Client.EnableSegmentData(); m_Client.EnableUnlabeledMarkerData(); m_Client.EnableDeviceData(); Output_Connect OC = m_Client.Connect(Host); print("Connect result: " + OC.Result); //data_UI.text = "Client connection success."; m_Client.EnableMarkerData(); m_Client.EnableSegmentData(); m_Client.EnableUnlabeledMarkerData(); m_Client.EnableDeviceData(); //m_Client.StartTransmittingMulticast(); System.Threading.Thread.Sleep(200); } if (UsePreFetch) { m_Client.SetStreamMode(StreamMode.ClientPullPreFetch); } else { m_Client.SetStreamMode(StreamMode.ServerPush); } if (UseLightweightData) { if (m_Client.EnableLightweightSegmentData().Result != Result.Success) { print("Unable to use lightweight segment data: Using standard segment data"); m_Client.EnableSegmentData(); } else { print("Using lightweight segment data"); } } else { print("Using standard segment data"); m_Client.EnableSegmentData(); } SetAxisMapping(Direction.Forward, Direction.Left, Direction.Up); //SetAxisMapping(Direction.Right, Direction.Up, Direction.Backward); ConnectionHandler(true); // Get frames in this separate thread if we've asked for it. while (GetFrameThread && bThreadRunning) { GetNewFrame(); } bThreadRunning = false; }