Beispiel #1
0
        public void Connect(NatNetConnectionType connType,
                            IPAddress localAddress,
                            IPAddress serverAddress,
                            UInt16 serverCommandPort   = NatNetConstants.DefaultCommandPort,
                            UInt16 serverDataPort      = NatNetConstants.DefaultDataPort,
                            IPAddress multicastAddress = null)
        {
            ThrowIfDisposed();

            sNatNetClientConnectParams initParams = new sNatNetClientConnectParams {
                ConnectionType    = connType,
                ServerCommandPort = serverCommandPort,
                ServerDataPort    = serverDataPort,
                LocalAddress      = localAddress.ToString(),
                ServerAddress     = serverAddress.ToString(),
                MulticastAddress  = multicastAddress == null ? null : multicastAddress.ToString()
            };

            NatNetError result;

            result = NatNetLib.NativeMethods.NatNet_Client_Connect(m_clientHandle, ref initParams);
            NatNetException.ThrowIfNotOK(result, "NatNet_Client_Connect failed.");

            result = NatNetLib.NativeMethods.NatNet_Client_GetServerDescription(m_clientHandle, out m_serverDesc);
            NatNetException.ThrowIfNotOK(result, "NatNet_Client_GetServerDescription failed.");

            ServerAppVersion = new Version(
                m_serverDesc.HostAppVersion[0],
                m_serverDesc.HostAppVersion[1],
                m_serverDesc.HostAppVersion[2],
                m_serverDesc.HostAppVersion[3]);

            Connected = true;
        }
Beispiel #2
0
        public NatNetClient(NatNetConnectionType connectionType)
        {
            NatNetError retval = NatNetLib.NativeMethods.NatNet_Client_Create(out m_clientHandle, connectionType);

            NatNetException.ThrowIfNotOK(retval, "NatNet_Client_Create failed.");

            if (m_clientHandle == IntPtr.Zero)
            {
                throw new NatNetException("NatNet_Client_Create returned null handle.");
            }

            // This ensures the reverse P/Invoke delegate passed to the native code stays alive.
            m_nativeFrameReceivedHandler = FrameReceivedNativeThunk;

            retval = NatNetLib.NativeMethods.NatNet_Client_SetFrameReceivedCallback(m_clientHandle, m_nativeFrameReceivedHandler);
            NatNetException.ThrowIfNotOK(retval, "NatNet_Client_SetFrameReceivedCallback failed.");
        }
Beispiel #3
0
        public void Connect(NatNetConnectionType connType,
                            IPAddress localAddress,
                            IPAddress serverAddress,
                            UInt16 serverCommandPort   = NatNetConstants.DefaultCommandPort,
                            UInt16 serverDataPort      = NatNetConstants.DefaultDataPort,
                            IPAddress multicastAddress = null)
        {
            ThrowIfDisposed();

            sNatNetClientConnectParams initParams = new sNatNetClientConnectParams {
                ConnectionType    = connType,
                ServerCommandPort = serverCommandPort,
                ServerDataPort    = serverDataPort,
                LocalAddress      = localAddress.ToString(),
                ServerAddress     = serverAddress.ToString(),
                MulticastAddress  = multicastAddress == null ? null : multicastAddress.ToString()
            };

            NatNetError retval = NatNetLib.NativeMethods.NatNet_Client_Connect(m_clientHandle, ref initParams);

            NatNetException.ThrowIfNotOK(retval, "NatNet_Client_Connect failed.");

            Connected = true;
        }
Beispiel #4
0
 public static extern NatNetError NatNet_Client_Create(out IntPtr clientHandle, NatNetConnectionType connectionType);