advices for a keepalive thread

Hello,

I'm working on a game to change from steam to photon. One of my main problem is the server timeouts. As I process photon message in the main thread, I got timeouts while the multiplayer game loading, where there is a lot of traffic and also the level loading which mean less framerate and then less updates that makes my game unable to respond to the server ping in time to avoid server disconnection.

So I thought of another thread that would have the responsability to process photon messages without the impact of the game framerate.

is it a good idea, how would you do / do you have advices that could help me ?

Thanks

Comments

  • KaiserludiKaiserludi admin
    edited December 2019

    Hi @benjaml.


    A better approach for this issue in my opinion would be to move the level loading into a separate thread to not let it effect the responsiveness of the main thread in the first place. An unresponsive main thread gives a bad user experience as it can't react to user input in a timely manner.

    If that is not easily achievable, then another option would be to split the level loading work up into multiple chunks of work and only do as many chunks of it within a single frame as can be done in a certain amount of time that is low enough to keep the frame rate reasonably high , then continue with more level loading work in the next frame and so on, until it is finished.


    Aside from that:

    In general having the network code in a separate thread makes sense, but you need to ensure that you don't access the same instance of the same Photon class from multiple different threads at once. So if you for example access the same instance of class LoadBalancing::Client from the main thread and from that separate thread, then you need to synchronize those accesses, i.e. with locks.

Sign In or Register to comment.