Esempio n. 1
0
        private void btnConnect_Click(object sender, RoutedEventArgs e)
        {
            if (connectorRef == IntPtr.Zero)
            {
                connectorRef = PN_DataReader.BRConnectTo(txtIP.Text, int.Parse(txtPort.Text));
                if (connectorRef == IntPtr.Zero)
                {
                    btnConnect.Content = "Connect";
                }
                else
                {
                    btnConnect.Content = "Disconnect";

                    counter = 0;
                }
            }
            else
            {
                if (connectorRef != IntPtr.Zero)
                {
                    PN_DataReader.BRDisconnect(connectorRef);
                    connectorRef       = IntPtr.Zero;
                    btnConnect.Content = "Connect";
                }
            }
        }
Esempio n. 2
0
 void OnApplicationQuit()
 {
     if (_connections.Count > 0)
     {
         if (PN_DataReader.BRGetConnectionStatus(_connections[0]) != SocketConnectionStatus.CS_Disconnected)
         {
             // disconnect
             PN_DataReader.BRDisconnect(_connections[0]);
         }
     }
 }
Esempio n. 3
0
    void OnGUI()
    {
        int boxW = 200;
        int boxH = 130;

        // border
        GUI.Box(new Rect(3, 3, boxW, boxH), "BVH Data Reader Settings");

        // Server IP
        GUI.Label(new Rect(20, 40, 120, 20), "Server IP:");
        ServerIP = GUI.TextField(new Rect(90, 40, 90, 20), ServerIP);

        // Server Port
        GUI.Label(new Rect(10, 70, 120, 20), "Server Port:");
        ServerPort = GUI.TextField(new Rect(90, 70, 90, 20), ServerPort);

        // connect button
        if (GUI.Button(new Rect(90, 100, 80, 20), _btnConnectString))
        {
            if (_connections.Count > 0)
            {
                if (PN_DataReader.BRGetConnectionStatus(_connections[0]) == SocketConnectionStatus.CS_Connected)
                {
                    PN_DataReader.BRDisconnect(_connections[0]);
                }
            }
            else
            {
                IntPtr connection = PN_DataReader.BRConnectTo(ServerIP, int.Parse(ServerPort));
                _connections.Add(connection);
                _receivedFramesCounter = 0;
            }
        }

        // Show debug inf:
        string ds1 = "Connection Status: \n";

        if (_IsSocketConnected)
        {
            ds1 += "Connected to: " + ServerIP.ToString() + ":" + ServerPort.ToString();
        }
        else if (_connections.Count > 0 && PN_DataReader.BRGetConnectionStatus(_connections[0]) == SocketConnectionStatus.CS_Disconnected)
        {
            ds1 += "Disconnected";
        }
        else
        {
            ds1 += "Connecting to: " + ServerIP + ":" + ServerPort;
        }
        GUI.color = Color.red;
        GUI.Label(new Rect(boxW + 10, 5, Screen.width - 40, 50), ds1);

        if (DEBUG_Enabled && _IsSocketConnected)
        {
            string ds2 = "BVH Data info: \n";
            ds2 += "With Displacement: " + _bvhHeader.bWithDisp + "\n" +
                   "With Reference: " + _bvhHeader.bWithReference + "\n" +
                   "Data Length: " + _bvhHeader.DataCount + "\n" +
                   "Received Frames: " + _receivedFramesCounter;
            GUI.color = Color.yellow;
            GUI.Label(new Rect(boxW + 10, 55, Screen.width - 40, Screen.height - boxH), ds2);
        }
    }