Download

TestBeaconHost and TestBeaconClient

I am playing around with the TestBeaconHost and TestBeaconClient

i have a c++ game instance subclass function that creates/spawns the host and initializes correctly
i have this set to call from another function marked with UFUNCTION(Server, Reliable, WithValidation)

I have another function that creates/spawns the testbeacon client and initializes on localhost
called from a function marked with UFUNCTION(Client, Reliable)

Now as far as I understood the documentation, on connection, it should “onClientConnected” start
the clientping->serverpong thing.

however i seem to be getting an annoying error that im failing to find a reasonable answer/explanation on why.

so when i press L i have it spawning the server, on another instance running when i press K it spawns the client
Server seems fine and spawns under Role_Authority

but the other one i get the following log output



LogTemp: ROLE_AutonomousProxy
LogTemp: Display: ParseSettings for GameNetDriver
LogTemp: Display: ParseSettings for IpNetDriver_4
LogInit: WinSock: Socket queue 32768 / 32768
PacketHandlerLog: Loaded PacketHandler component: Engine.EngineHandlerComponentFactory (StatelessConnectHandlerComponent)
LogNet: Game client on port 7777, rate 10000
LogNet: Warning: Client is absorbing remote function ServerPong on actor TestBeaconClient_0 because RemoteRole is ROLE_None


As far as I can see, and please correct me if I am wrong, i have set the TestBeaconClient to spawn on client but it has no replication?

i went into the ATestBeaconClient.cpp and added to the constructor
bReplicates = true;

but same issue, ive tried multiple combinations of hasAuthority and is server but i dont seem to be making any progress.

can anyone shed any light on it?

Ahh ok, sorted

it turns out the host when you subclass you need


    virtual void OnClientConnected(class AOnlineBeaconClient* NewClientActor, class UNetConnection* ClientConnection) override;
    virtual AOnlineBeaconClient* SpawnBeaconActor(class UNetConnection* ClientConnection) override;

and you need to specify which ClientBeaconActorClass its using in the constructor otherwise it wont spawn the right class or have the right overrides to call and falls out, dont ask me why but i tried each step without and apparently i needed all 3 set.

also when spawning these, it doesnt need to be set to “run as server/client”.
on 1 instance you just call/spawn the host it and it will initialize locally,
on the other instance you are creating the client locally and for example (if testing locally) you set the url address to 127.0.0.1 and port to 7787 and init host

with this the serverhost will replicate and create a new client server side for it to talk to itself and the serverpong client ping are already set up as run on server/client so all good :slight_smile:

found this article that helped a lot