It does not work.
I have added this code in TestNetworkCharacter.h
void ChangeTest(int32 Value);
UFUNCTION(reliable, server, WithValidation)
void ServerChangeTest(int32 Value);
And this code to TestNetworkCharacter.cpp
void ATestNetworkCharacter::ChangeTest(int32 Value)
{
UE_LOG(LogSomething, Log, TEXT("Entering function"));
Test = Value;
if (Role < ROLE_Authority)
{
UE_LOG(LogSomething, Log, TEXT("Call the server"));
ServerChangeTest(Value);
}
}
bool ATestNetworkCharacter::ServerChangeTest_Validate(int32 Value)
{
UE_LOG(LogSomething, Log, TEXT("Validate"));
return true;
}
void ATestNetworkCharacter::ServerChangeTest_Implementation(int32 Value)
{
UE_LOG(LogSomething, Log, TEXT("Implementation"));
ChangeTest(Value);
}
I have changed the code of the function Action2() by this one
void ATestNetworkCharacter::Action2()
{
ChangeTest(2);
}
For me, the function ChangeTest have to be call from the client, to go inside the if. But it’s look not good, because important change must be run from the server, not from the client. The server must stay the king.
By the way, here come my test procedure :
- Launch the server and next the client
- Hit the key to log value on server and after on client
- Hit the key to call Action2() from the client
- Repeat the step 2
Inside server logs I have
[2014.04.21-23.23.31:304][391]LogSomething: Server 1
[2014.04.21-23.23.35:068][533]LogSomething: Validate
[2014.04.21-23.23.35:069][533]LogSomething: Implementation
[2014.04.21-23.23.35:069][533]LogSomething: Entering function
[2014.04.21-23.23.39:180][688]LogSomething: Server 1
And inside de client log I have
[2014.04.21-23.23.33:178][768]LogSomething: Client 1
[2014.04.21-23.23.35:056][839]LogSomething: Entering function
[2014.04.21-23.23.35:056][839]LogSomething: Call the server side
[2014.04.21-23.23.37:266][923]LogSomething: Client 2
Then, the client change the value, call the server-side function, the server seems to execute the same function but finaly does not change the value because le final log show Server 1 in place of server 2.
Where is my mistake ?