Example #1
0
        public RetCode registerListener(HubListener ls)
        {
            RetCode ret = RetCode.GF_SUCCESS;

            if (mListeners.Add(ls))
            {
                if (mListeners.Count() == 1)
                {
                    mListenerDele = new libgforce.ListenerDelegate();
                    mListenerDele.onScanfinishedFn        = new libgforce.onScanfinished(Hub.onScanfinishedImpl);
                    mListenerDele.onStateChangedFn        = new libgforce.onStateChanged(Hub.onStateChangedImpl);
                    mListenerDele.onDeviceFoundFn         = new libgforce.onDeviceFound(Hub.onDeviceFoundImpl);
                    mListenerDele.onDeviceDiscardFn       = new libgforce.onDeviceDiscard(Hub.onDeviceDiscardImpl);
                    mListenerDele.onDeviceConnectedFn     = new libgforce.onDeviceConnected(Hub.onDeviceConnectedImpl);
                    mListenerDele.onDeviceDisconnectedFn  = new libgforce.onDeviceDisconnected(Hub.onDeviceDisconnectedImpl);
                    mListenerDele.onOrientationDataFn     = new libgforce.onOrientationData(Hub.onOrientationDataImpl);
                    mListenerDele.onGestureDataFn         = new libgforce.onGestureData(Hub.onGestureDataImpl);
                    mListenerDele.onDeviceStatusChangedFn = new libgforce.onDeviceStatusChanged(Hub.onDeviceStatusChangedImpl);
                    mListenerDele.onExtendedDeviceDataFn  = new libgforce.onExtendedDeviceData(Hub.onExtendedDeviceDataImpl);

                    ret = libgforce.hub_register_listener(ref mListenerDele);
                }
            }
            else
            {
                // if already added, do nothing but return GF_SUCCESS
            }
            return(ret);
        }
Example #2
0
        private void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    // free IDisposable managed objects
                }
                mListeners.Clear();
                mDevices.Clear();
                mListenerDele = new libgforce.ListenerDelegate();
                // free unmanaged objects
                deinit();

                _disposed = true;
            }
        }