room connection and detecting disconnect

hi.
I need some help with two issues regarding connection to the game on photon cloud server, and on events of player disconnecting form the server.

1. our game needed to list all users currently using the game so we implemented our own lobby for the game. players search for other available players and pick their opponent. when they agree to play, they are given unique game name using player's names and timecode. after that, they connect to the exit games cloud. Player 1 is creating the game room, and start waiting for other player listening the join event. In the mean time the other player is listening for game list change events. When the room with given name appear in the list, player joins the room. This worked fine while testing, however, now when operating on production server our users often experience that game doesn't start.
We have timer set to 30 seconds to wait for players to connect and after that user is informed that they didn't connect to the game server.
When everything works fine players are connected very fast and everything works fine. But often they don't connect.

Is there a better way to do this and can you give some idea on what might go wrong during the connection?

2. My second question is about detecting when client is disconnected from the server. We are listening for player left event in the game room and this works as expected. For example if player 1 closes the browser window we inform the player 2 that other player has left the game. But sometime, for example, player 1 loses the connection while playing the game and player 2 gets the message, but other player is still playing the game. Is there a simple way to detect if custom events are dispatched successfully?

i am using Photon Flash RC4 SDK

thanks in advance

Comments

  • The matchmaking is a little more complex than needed.
    If players know each other and exchange a timestamp, you can turn that into a room name: userA+userB+TimeStamp
    You don't have to wait for roomlist changes this way. Simple let one player create the room and the other join it. No need to even get the room list. You could modify the loadbalancing part to not join the lobby, if the name is known. If the room does not exist, then you could simply retry join after a moment and stop this loop when it's taking too long.

    Why they don't connect?
    There is no reason to not connect within your workflow, so it's unclear. If the clients connect and create the room within 30 seconds (your timing), then it should work. Otherwise, there must be some kind of error. Make the client check OnStatusUpdate for errors.


    The leave event is there to let you know if another player left the room. It's not about "this" client's connection.
    The connection can become lost, even though the client is still running. The clients have to ping the server in intervals, so that the connection isn't considered lost.
    This should be done behind the scenes and without you taking care of, except when the client freezes for a while or so. Please make sure this is not the case.

    Each peer has a "isConnected" property which tells you if "this" client is still connected. If it's not, operations will not be sent and the other will not receive anything.

    Can we somehow check your game out or reproduce the issue?
  • thanks for the fast reply.
    yes, i am generating the room name like you are suggesting, but i didn't know that i can skip joining the lobby. i will review my code and try that, and make sure i am listening for onStatusUpdate.
    For the problem of disconnecting from the server i can then check "isConnected" property before sending any messages.
    thanks.
    i will report the results here.

    of course you can check out the game. :)
    Challenger Sudoku
    https://apps.facebook.com/244946772280792/
  • i revisited the code for connecting to game room. now users are connecting directly to the game server. and did about 100 test connections without a glitch, and clients now connect much faster. thanks again. didn't have time to review the second part of the problem (when user disconnects and property isConnected).
    thanks for your help again
  • You're welcome! Glad it helps so quickly.
  • hi.
    for the second part of the problem "isConnected" parameter doesn't seem to work.
    to test this i am checking the "isConnected" parameter before any custom message sent, and when i disconnect the internet connection completely the "isConnected" property still returns true
  • That is correct.
    Until the timeout is detected, which can take up to 20s depending on your hardware etc, you are connected cause the line does not know it went missing.

    thats a common problem that no game can get around actually.
    What games therefor do is normally send an 'alive signal' which the client uses to inform the user of connection problems when they are not received for too long so the user is prewarned that he potentially might drop out any time so he can force restart the app himself etc
  • dreamora, generative is talking about the same client. There is of course no delay when you call disconnect and then check isConnected.
    generative: This must be a bug then.

    Could you please use the preview RC7: viewtopic.php?f=9&t=1705
    If that's also affected, we can take a look easily.
  • with RC7 i get the same results
  • We have to check this but it will take a few days, I fear.
    Sorry for the delay.
  • We had a look at the code and checked the options we have but didn't get far.
    This seems to be an issue on Adobe's side of things: New Flash players will delay the event for socket network loss 20seconds. No error for socket.write or any other hint before that timeout happens.

    Please let Adobe know about it. This is the only hint we could find that there are others with similar issues:
    http://forums.adobe.com/message/4232903

    Sorry for the bad news.
  • is there some other way to detect this? listen for some other event sent periodically and detect when it's gone?
    i would send some custom message in smaller time periods than 20 seconds but you are limiting number of messages per room to 500.
  • No. There is no other way we know of. Flash is silent until the time's up. We don't get any feedback from the socket layers.
    It's not a matter of sending something in 20 seconds. It's a matter of Flash not reacting at all, no matter what we do in those 20 seconds.

    Go and make Adobe aware of this. The more people raise this issue, the better are chances they improve it.
  • Ok. What i was talking about matters if i send something in the same time periods, if that signal is gone i would know that the connection is lost.
    thanks again for fast answers