How to determine state changes in "Hello World" example.


I'm unclear in the Corona Hello World example how to determine the state of the client; i.e. when it connects to a lobby, then connects to a room, etc.. etc..

How can I check for these different states? I didn't want to display any game info or GUI until the connection is confirmed to the room.

For example, this code here:

function client:onOperationResponse(errorCode, errorMsg, code, content)
self.logger:debug("onOperationResponse", errorCode, errorMsg, code, tableutil.toStringReq(content))
if errorCode ~= 0 then
if code == LoadBalancingConstants.OperationCode.JoinRandomGame then -- master random room fail - try create
self.logger:error(errorCode, errorMsg)

It seems the client is awaiting a OperationResponse, and somehow if this: "LoadBalancingConstants.OperationCode.JoinRandomGame" is received, the client is instructed to try to join a random game, will fail, then will create a room called "helloworld".

But *where* is that "LoadBalancingConstants.OperationCode.JoinRandomGame" getting called? I guess, I could really use a breakdown of the lifecycle of a PhotonCloud realtime client.

But I'll take any help I can get here. I plan on using you guys along with PlayFab to handle a turn based game when all is said and done.

You'll be hearing a lot from me in the future I'm sure. :)



  • Hi,

    The simplest way to trace client state is implement onStateChange method.
    See usage sample in demo-particle\ParticleClient.lua and other demos.

    client:onOperationResponse in code snipped you quoted is used for detecting random matchmaking error. This is probably the only case you may need that not covered by onStateChange.
Sign In or Register to comment.