예제 #1
0
 public ulong Add(NetStream streamValue) {
     NetStream stream = streamValue.Copy();
     ulong key = RandomUlong();
     ulongKeys.Add(key);
     stringKeys.Add(EmptyString);
     streams.Add(stream);
     return key;
 }
예제 #2
0
 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;
 }
예제 #3
0
 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;
 }