Skip to content
Snippets Groups Projects
Commit 167e10de authored by Jonathan Ehret's avatar Jonathan Ehret
Browse files

adde more comments, and als a register method beforehand

parent c358d49b
No related branches found
No related tags found
No related merge requests found
...@@ -21,14 +21,19 @@ void UClusterSyncedMethodCaller::DeregisterListener() { ...@@ -21,14 +21,19 @@ void UClusterSyncedMethodCaller::DeregisterListener() {
} }
} }
void UClusterSyncedMethodCaller::CallMethodSynced(FSyncMethod MethodToCall, TMap<FString, FString> Parameters, FString UniqueIdentifier) void UClusterSyncedMethodCaller::CallMethodSynced(FString UniqueIdentifier, TMap<FString, FString> Parameters)
{ {
check(SyncedFunctions.Contains(UniqueIdentifier))
IDisplayClusterClusterManager* const Manager = IDisplayCluster::Get().GetClusterMgr(); IDisplayClusterClusterManager* const Manager = IDisplayCluster::Get().GetClusterMgr();
if (Manager) if (Manager)
{ {
if (Manager->IsStandalone()) { if (Manager->IsStandalone()) {
//in standalone (e.g., desktop editor play) cluster events are not executed.... //in standalone (e.g., desktop editor play) cluster events are not executed....
MethodToCall.Execute(Parameters); if (SyncedFunctions.Contains(UniqueIdentifier)) {
SyncedFunctions.FindChecked(UniqueIdentifier).Execute(Parameters);
}
} }
else { else {
// else create a cluster event to react to // else create a cluster event to react to
...@@ -37,11 +42,15 @@ void UClusterSyncedMethodCaller::CallMethodSynced(FSyncMethod MethodToCall, TMap ...@@ -37,11 +42,15 @@ void UClusterSyncedMethodCaller::CallMethodSynced(FSyncMethod MethodToCall, TMap
cluster_event.Type = "ClusterSyncedMethodCaller"; cluster_event.Type = "ClusterSyncedMethodCaller";
cluster_event.Name = UniqueIdentifier; cluster_event.Name = UniqueIdentifier;
cluster_event.Parameters = Parameters; cluster_event.Parameters = Parameters;
Manager->EmitClusterEvent(cluster_event, true);
SyncedFunctions.Add(UniqueIdentifier, MethodToCall); Manager->EmitClusterEvent(cluster_event, true);
}
} }
} }
void UClusterSyncedMethodCaller::RegisterSyncedMethod(FString UniqueIdentifier, FSyncMethod MethodToCall)
{
SyncedFunctions.Add(UniqueIdentifier, MethodToCall);
} }
void UClusterSyncedMethodCaller::HandleClusterEvent(const FDisplayClusterClusterEvent & Event) void UClusterSyncedMethodCaller::HandleClusterEvent(const FDisplayClusterClusterEvent & Event)
......
...@@ -24,11 +24,12 @@ public: ...@@ -24,11 +24,12 @@ public:
//DeregisterListener() should be called in EndPlay() //DeregisterListener() should be called in EndPlay()
void DeregisterListener(); void DeregisterListener();
//This will call MethodToCall in a synced manner with parameters, also works in non-cluster mode, notive that in this case this call is synced between all nodes, but async to the call of this method! //This will call a with UniqueIdentifier registered method in a synced manner with given parameters, also works in non-cluster mode.
//UniqueIdentifier should be unique to any call of this method of any object! //Notice that in the cluster case this call is synced between all nodes, but async to the call of this method!
//template<class UserClass> void CallMethodSynced(FString UniqueIdentifier, TMap<FString, FString> Parameters);
//void CallMethodSynced(UserClass* UserObject, void(UserClass::*Function)(TMap<FString, FString>), TMap<FString, FString> parameters, FString unique_identifier);
void CallMethodSynced(FSyncMethod MethodToCall, TMap<FString, FString> Parameters, FString UniqueIdentifier); //Register a method to be called in a synced manner, UniqueIdentifier should be unique to any call of this method of any object!
void RegisterSyncedMethod(FString UniqueIdentifier, FSyncMethod MethodToCall);
private: private:
FOnClusterEventListener ClusterEventListenerDelegate; FOnClusterEventListener ClusterEventListenerDelegate;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment