You can freely extend the GridMate interest manager system with your own logic. To
create
a custom rule handler, inherit and implement the GridMate::BaseRulesHandler C++
interface. The following snippet shows the code for the BaseRulesHandler
class.

Of interest is the method GetLastResult, which returns
InterestMatchResult. InterestMatchResult is essentially an
unordered map between replicas and a list of the peers on which the replicas should
be
present. If a peer is not on the list for a replica and has the replica's proxy, interest
manager removes the replica's proxy. The following code shows the declaration of the
InterestMatchResult class.

Copy

// dev\Code\Framework\GridMate\GridMate\Replica\Interest\InterestDefs.h
using InterestPeerSet = unordered_set<PeerId>;
/**
* InterestMatchResult: a structure to gather new matches from handlers.
* Passed to handler within matching context when handler's Match method is invoked.
* User must fill the structure with changes that handler recalculated.
*
* Specifically, the changes should have all the replicas that had their list of associated peers modified.
* Each entry replica - new full list of associated peers.
*/
class InterestMatchResult : public unordered_map<ReplicaId, InterestPeerSet>

It's up to you to decide how you want your rule handler to match up rules and attributes.
To help you get started, GridMate provides some simple base classes for rules and
attributes, as the following code shows.

For more details and examples, see the code for
GridMate::BitmaskInterestHandler and
GridMate::ProximityInterestHandler. The associated source code files are in
the Lumberyard directory
dev\Code\Framework\GridMate\GridMate\Replica\Interest.