Class NetKeyTable<T>
- Namespace
- Unity.Multiplayer.Core
Live objects by their network key (UM-T60), the engine-free core of the adapter's NetRegistry: at most one
item per key, a second claim on a held key refused, and a removal honoured only for the item that holds the key
(so a late despawn of an old object never unregisters the new one that took its key).
public sealed class NetKeyTable<T> where T : class
Type Parameters
T
- Inheritance
-
NetKeyTable<T>
- Inherited Members
Remarks
Not thread-safe; the adapter uses it from Unity's main thread.
Properties
Count
How many keys are held.
public int Count { get; }
Property Value
Items
Every item that holds a key (a copy).
public IReadOnlyList<T> Items { get; }
Property Value
Keys
Every held key (a copy).
public IReadOnlyList<string> Keys { get; }
Property Value
Methods
Add(string, T, out T)
Gives item key unless the key is invalid or another item holds it.
public NetKeyAddResult Add(string key, T item, out T holder)
Parameters
keystringThe key to claim.
itemTThe item claiming it.
holderTThe item holding the key afterwards (the existing one on Duplicate); null for an invalid key.
Returns
Exceptions
- ArgumentNullException
itemis null.
Clear()
Forgets every key.
public void Clear()
Contains(string)
True when some item holds key.
public bool Contains(string key)
Parameters
keystring
Returns
Get(string)
The item holding key.
public T Get(string key)
Parameters
keystring
Returns
- T
Exceptions
- KeyNotFoundException
No item holds it (NotFoundMessage(string)).
Remove(string, T)
Frees key if item holds it.
public bool Remove(string key, T item)
Parameters
keystringitemT
Returns
- bool
True when the key was freed; false when it is unknown or held by another item.
TryGet(string, out T)
The item holding key.
public bool TryGet(string key, out T item)
Parameters
keystringitemT