Download

Persistent Objects - Register a Timer without a World

Hey there, iam curently playing with the FSocket Class, however iam wondering, what would be the the best place to put them? I want to have a constant connection to a external TCP-Server across several levels. I have implemented the stuff in the Gameinstance for the Client and in the Gamemode for the Dedicated Server (Booth need to be connected to the TCP-Server). The Dedicated Server - Gamemode Implementation is pretty stright forward as i can use the Tick event to grab eventually received data. But for the Client i cannot find a good place to put the stuff. The GameInstance is persistent trough levelchange but it has no ticking capability so iam a little lost on how to check for receveived data. I can use timers but i will have to register the timers everytime i have a levelchange… Does someone have an idea on how to solve this puzzle :)?

You can register a timer inside your GameInstance, that’s how Epic did it in the ShooterGame, for example.

Just add something like that to your Init() method:


FTickerDelegate TickDelegate = FTickerDelegate::CreateUObject(this, &UYourGameInstance::Tick);

// If you want to keep this handle around then declare it in your header
TickDelegateHandle = FTicker::GetCoreTicker().AddTicker(TickDelegate);

Oh thank you ill have a look into that. Cookie for you