static void connectToServer() { // [NatNet] Instantiate the client object mNatNet = new NatNetClientML(); // [NatNet] Checking verions of the NatNet SDK library int[] verNatNet = new int[4]; // Saving NatNet SDK version number verNatNet = mNatNet.NatNetVersion(); // Console.WriteLine("NatNet SDK Version: {0}.{1}.{2}.{3}", verNatNet[0], verNatNet[1], verNatNet[2], verNatNet[3]); // [NatNet] Connecting to the Server // Console.WriteLine("\nConnecting...\n\tLocal IP address: {0}\n\tServer IP Address: {1}\n\n", mStrLocalIP, mStrServerIP); NatNetClientML.ConnectParams connectParams = new NatNetClientML.ConnectParams(); connectParams.ConnectionType = mConnectionType; connectParams.ServerAddress = mStrServerIP; connectParams.LocalAddress = mStrLocalIP; mNatNet.Connect(connectParams); }
public void Connect(string clientIp, string serverIp, string connectionType) { /* [NatNet] Instantiate the client object */ _natNetClient = new NatNetClientML(); /* [NatNet] Checking verions of the NatNet SDK library */ var natNetVersion = _natNetClient.NatNetVersion(); Logger.Info("NatNet SDK Version: {0}.{1}.{2}.{3}", natNetVersion[0], natNetVersion[1], natNetVersion[2], natNetVersion[3]); /* [NatNet] Connecting to the Server */ Logger.Info("\nConnecting...\n\tLocal IP address: {0}\n\tServer IP Address: {1}\n\n", clientIp, serverIp); var connectParams = new NatNetClientML.ConnectParams { ConnectionType = connectionType == "unicast" ? ConnectionType.Unicast : ConnectionType.Multicast, ServerAddress = serverIp, LocalAddress = clientIp }; _natNetClient.Connect(connectParams); _isConnected = FetchServerDescription(); if (_isConnected) { _natNetClient.OnFrameReady += NatNetClientOnOnFrameReady; } else { throw new ApplicationException("Could not connect to optitrack"); } }
public void TryConnect() { if (client != null) { //client.Disconnect(); } Rhino.RhinoApp.Write("Attemping to connect to NatNet server... "); client = new NatNetClientML(); var cp = new NatNetClientML.ConnectParams(); cp.ConnectionType = ConnectionType.Multicast; cp.LocalAddress = "127.0.0.1"; cp.ServerAddress = "127.0.0.1"; cp.ServerCommandPort = 1510; cp.ServerDataPort = 1511; int res = client.Connect(cp); if (res != 0) { Rhino.RhinoApp.WriteLine("Failed."); client = null; IsConnected = false; return; } Rhino.RhinoApp.WriteLine("Success."); IsConnected = true; fetchServerDescriptor(); client.OnFrameReady += new NatNetML.FrameReadyEventHandler(fetchFrameData); Rhino.RhinoDoc.ActiveDoc.Views.Redraw(); }