public ulong Add(NetStream streamValue) { NetStream stream = streamValue.Copy(); ulong key = RandomUlong(); ulongKeys.Add(key); stringKeys.Add(EmptyString); streams.Add(stream); return key; }
public bool TryAdd(string stringKey, NetStream streamValue, out ulong key) { NetStream stream = streamValue.Copy(); if (string.IsNullOrEmpty(stringKey)) { Debug.LogError("TryAdd failed! String key is null or empty."); key = ulong.MinValue; return false; } if (stringKeys.Contains(stringKey)) { Debug.LogError("TryAdd failed! Database already contains provided string key: " + stringKey); key = ulong.MinValue; return false; } key = RandomUlong(); ulongKeys.Add(key); stringKeys.Add(stringKey); streams.Add(stream); return true; }
public bool TryUpdate(ulong ulongKey, NetStream stream) { int index; if (stream == null || !TryGetIndex(ulongKey, out index)) return false; NetStream oldStream = streams[index]; streams[index] = stream.Copy(); if (stream != oldStream) oldStream.Release(); return true; }