Client <-> server communication... again...

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

lazy303

New Member
Sep 20, 2004
13
0
0
I have an Interaction class (on the client) which in the PostRender function calls a function on the server. The server function is supposed to return a bool. The client allways gets a false even if I return true from the server.
I guess the client doesn't wait for the server to respond so it will
allways be false.
Am I right about that? Is there some good solution?

/lazy
 

Kamek

Magikoopa
Sep 26, 2004
10
0
0
bastard.popexperiment.com
Try something like this.

Code:
class NewInteraction extends Interaction;

var bool bReturnProperty;

replication
{
	// Stuff the server needs to send to the client
	unreliable if (Role == ROLE_Authority && bNetDirty)
		bReturnProperty;

	// Stuff the client must send to the server
	unreliable if (Role < ROLE_Authority)
		CallServerFunction;
}

function bool ReturnABool()
{
	// Stuff you needed to do server-side goes here.
	return SomeBooleanValue;
}

function CallServerFunction()
{
	// This calls the function on the server and stores the return value in
	// bReturnProperty.
	if (Role = ROLE_Authority)
		bReturnProperty = ReturnABool();
}

simulated function PostRender(canvas Canvas)
{
	if (Level.NetMode != NM_DedicatedServer)
	{
		// Your code goes here
		CallServerFunction();
	}
	// Whenever the server gets done processing whatever it is you needed
	// on the client, bReturnProperty will be set. For now, continue
	// processing code as though bReturnProperty was set.
}

The function call will pass to the server for each PostRender, but since it's unreliable it will only be executed if bandwidth is available, and the server will return the value in bReturnProperty whenever bandwidth is available. Until the server replicates that bReturnProperty, PostRender just uses whatever value was there before.

Hope this helps some..