What is the callback flow when the loadbalancing client connect method is called?

Exactly what it says on the tin. If there is a flowchart it would be even better. Also related, when connect returns true does that mean no connection errors happened or are there errors that require the listener to be fully implemented?

cheers!

Best Answer

  • Kaiserludi
    Kaiserludi admin
    edited March 2017 Answer ✓
    Hi @CASBraga.

    Client::connect::() starts establishing a connection to a Photon server.

    The connection is successfully established when the Photon client received a valid response from the server. The connect-attempt fails when a network error occurs or when server is not responding.

    A call to connect() starts an asynchronous operation. The result of this operation gets returned through the Listener::connectReturn() callback function.

    If this function returns false, then the connect-attempt has already failed locally.
    If it returns true, then either Listener::connectionErrorReturn() or Listener::connectReturn() will get called.

    The operation was successful, when Listener::connectReturn() got called with errorCode==0.

Answers

  • Kaiserludi
    Kaiserludi admin
    edited March 2017 Answer ✓
    Hi @CASBraga.

    Client::connect::() starts establishing a connection to a Photon server.

    The connection is successfully established when the Photon client received a valid response from the server. The connect-attempt fails when a network error occurs or when server is not responding.

    A call to connect() starts an asynchronous operation. The result of this operation gets returned through the Listener::connectReturn() callback function.

    If this function returns false, then the connect-attempt has already failed locally.
    If it returns true, then either Listener::connectionErrorReturn() or Listener::connectReturn() will get called.

    The operation was successful, when Listener::connectReturn() got called with errorCode==0.
  • CASBraga
    CASBraga
    edited March 2017
    Hi @Kaiserludi

    Thanks for the swift answer. Is there any reason neither Listener::connectReturn() nor Listener::connectionErrorReturn() would not be called during the connection process? I ask this because I have an implementation of both in my LoadBalancing::Listener (along with the client, warning and server error functions) but there is no call to them (strings initialized inside of them are passed to my GameInstance class to be printed; using UE4 btw). I know Client::connect() returns true when called. I also know it is not a network issue as the particle demo works fine and I tested a demo that comes with the SDK and also got connection to the photon cloud.

    cheers!
  • Hi @CASBraga.

    Are you sure that you are passing the correct listener instance to the Client constructor?
  • CASBraga
    CASBraga
    edited March 2017
    Edit: removed my own code since it is no longer necessary.

    To get a call to connectReturn and any other function from the Listener just make sure to call Client::service() after you call Client::connect(). That was my problem. Once service() was called in tick(), the test project connected. So yes, nothing to do with the Listener... just good old fashioned lack of attention when reading the documentation. :wink:

    Cheers!