public LocalDataChangedKey registerLocalDataListener(string simId, string key, LocalDataChangedDelegate localDataChangedDelegate) { string jsonString = SimCapiJsonMaker.create_REGISTER_LOCAL_DATA_CHANGE_LISTENER(_handshake, key, simId); if (_localDataChangedCallbacks.ContainsKey(simId) == false) { _localDataChangedCallbacks[simId] = new Dictionary <string, LocalDataChangedKey>(); } LocalDataChangedKey newKey = new LocalDataChangedKey(localDataChangedDelegate, simId, key); _localDataChangedCallbacks[simId][key] = newKey; sendMessage(jsonString); return(newKey); }
public void unregisterLocalDataListener(LocalDataChangedKey localDataChangedKey) { string simId = localDataChangedKey.simId; string key = localDataChangedKey.key; if (_localDataChangedCallbacks[simId] == null) { return; } if (_localDataChangedCallbacks[simId][key] == null) { return; } _localDataChangedCallbacks[simId].Remove(key); if (_localDataChangedCallbacks[simId].Count == 0) { _localDataChangedCallbacks.Remove(simId); } localDataChangedKey.invalidateKey(); }