class GreedyAuthorityReplicator (Niantic.ARDK.Networking.HLAPI.Authority.GreedyAuthorityReplicator)
Overview
IAuthorityReplicator That will greedily take roles. If it can be proven locally that the role is able to be taken by the local peer, then the local peer will assume it can take the role, otherwise it will fail. This can result in race conditions if two peers try to claim a role at the same time so it should only be used in scenarios where authority can be statically determined (such as authority is always host). More…
class GreedyAuthorityReplicator: Niantic.ARDK.Networking.HLAPI.NetworkedDataHandlerBase, Niantic.ARDK.Networking.HLAPI.Authority.IAuthorityReplicator { public: // properties Role? LocalRole; // methods GreedyAuthorityReplicator(string identifier, INetworkGroup group); IReadOnlyCollection<IPeer> PeersOfRole(Role role); Role RoleOfPeer(IPeer peer); void TryClaimRole(Role role, Action onPass, Action onFail); };
Inherited Members
public: // fields static readonly object NothingToWrite = new object(); // properties INetworkGroup Group; string Identifier; INetworkGroup Group; string Identifier; Role LocalRole; // methods void Unregister(); IPeer GetSelfOrNull(); virtual void Unregister(); IReadOnlyCollection<IPeer> PeersOfRole(Role role); Role RoleOfPeer(IPeer peer); void TryClaimRole(Role role, Action onPass, Action onFail);
Detailed Documentation
IAuthorityReplicator That will greedily take roles. If it can be proven locally that the role is able to be taken by the local peer, then the local peer will assume it can take the role, otherwise it will fail. This can result in race conditions if two peers try to claim a role at the same time so it should only be used in scenarios where authority can be statically determined (such as authority is always host).
Methods
GreedyAuthorityReplicator(string identifier, INetworkGroup group)
Parameters:
identifier |
The identifier of this |
group |
The group to use |
IReadOnlyCollection<IPeer> PeersOfRole(Role role)
Gets all peers that are of a given role. This method should never return null, if needed an empty collection is returned.
Role RoleOfPeer(IPeer peer)
Gets the role of a peer.
void TryClaimRole(Role role, Action onPass, Action onFail)
Trys to claim a role for the local peer.
Parameters:
role |
The role to claim. |
onPass |
Called if the role could be claimed. |
onFail |
Called if the role could not be claimed. |