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); }
public RetCode unregisterListener(HubListener ls) { RetCode ret = RetCode.GF_SUCCESS; if (mListeners.Remove(ls)) { if (mListeners.Count() == 0) { ret = libgforce.hub_unregister_listener(ref mListenerDele); } } else { // if not exists ret = RetCode.GF_ERROR; } return(ret); }