Exemple #1
0
        public void Start()
        {
            if (_isRunning)
            {
                return;
            }

            eLeapRS result;

            if (_leapConnection == IntPtr.Zero)
            {
                if (ConnectionKey.serverNamespace == null)
                {
                    result = LeapC.CreateConnection(out _leapConnection);
                }
                else
                {
                    LEAP_CONNECTION_CONFIG config = new LEAP_CONNECTION_CONFIG();
                    config.size             = (uint)Marshal.SizeOf(config);
                    config.flags            = 0;
                    config.server_namespace = Marshal.StringToHGlobalAnsi(ConnectionKey.serverNamespace);
                    result = LeapC.CreateConnection(ref config, out _leapConnection);
                    Marshal.FreeHGlobal(config.server_namespace);
                }

                if (result != eLeapRS.eLeapRS_Success || _leapConnection == IntPtr.Zero)
                {
                    reportAbnormalResults("LeapC CreateConnection call was ", result);
                    return;
                }
            }
            result = LeapC.OpenConnection(_leapConnection);
            if (result != eLeapRS.eLeapRS_Success)
            {
                reportAbnormalResults("LeapC OpenConnection call was ", result);
                return;
            }
            // The Allocator must persist the lifetime of the connection
            if (_pLeapAllocator.allocate == null)
            {
                _pLeapAllocator.allocate = MemoryManager.Pin;
            }
            if (_pLeapAllocator.deallocate == null)
            {
                _pLeapAllocator.deallocate = MemoryManager.Unpin;
            }
            LeapC.SetAllocator(_leapConnection, ref _pLeapAllocator);

            _isRunning = true;
            AppDomain.CurrentDomain.DomainUnload += (arg1, arg2) => Dispose(true);

            _polster              = new Thread(new ThreadStart(this.processMessages));
            _polster.Name         = "LeapC Worker";
            _polster.IsBackground = true;
            _polster.Start();
        }
Exemple #2
0
 public static extern eLeapRS CreateConnection(ref LEAP_CONNECTION_CONFIG pConfig, out IntPtr pConnection);
Exemple #3
0
 public static extern eLeapRS CreateConnection(ref LEAP_CONNECTION_CONFIG pConfig, out IntPtr pConnection);