RaiseEvent failing. Event can't be sent!

Options
FGk
FGk
As title says I have a problem with RaiseEvent() function.
I am trying to call RaiseEvent() inside OnLeftRoom()method but event can't be sent. I am almost sure the reason is that the player has already left the room when the event is trying to be sent. I am trying to find a way to delay player disconnect but I am afraid I can't find anything.
Any suggestions?

Comments

  • Nobrega
    Options
    What are you trying to accomplish with the event? You could use OnPhotonPlayerDisconnected if you're trying to send something to the players that are still in the room.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @FGk,

    Thank you for choosing Photon!

    Player can unexpectedly and unwillingly disconnect sometimes.
    In the normal scenario, player can send an event before leaving the room.
    You need to take into consideration worst cases.
  • FGk
    Options
    Hi guys!
    @Nobrega , I want to raise an event from the player who left the room or disconnected. That's why I am trying to use OnLeftRoom(). In other words, I want to send an event from the client that left the game, I don't want to send an event from MasterClient when somebody disconnects. I don't know if OnPhotonPlayerDisconnected() can work in my case.

    @JohnTube , that's what I am trying to do. I am not seeking a solution just for a player leaving the room, but also for a player disconnectiing unexpectedly. As I said before, right now I am raising an event inside OnLeftRoom() method, but it isn't working. If you know what I could do alternatively, I would be grateful!
  • Kaiserludi
    Options
    Hi @FGk.

    Well think for a moment about what you have just written:
    After a player has just lost its connection, you want to have it send the info "hey, I have just disconnected" to the other players. Of course that is not possible, because how should the message be transferred to the other players, if the sender is no longer connected?

    That is like when your phone turns off because it ran out of battery and and then trying to call someone with that turned off phone to inform him about the fact that your phone has turned off and you therefor can no longer call him/her.
  • FGk
    Options
    Hi @Kaiserludi,

    I know what I have written and I also know that it sounds impossible to handle this case. However, I was hoping there is a way to raise the event just a milisecond or something before the player lose his connection. I guess I have to go with plan B, which means MasterClient will raise the event when a player leaves.

    Thanks for helping me guys!
  • Kaiserludi
    Options
    Well, how would PUN or your game code know, that the player will loose its connection one ms in the future?
    Imagine for example a player unplugs the Ethernet cable of his PC. How should PUN predict that and when this will happen before the connection is already lost?
  • FGk
    Options
    It can't, you are right @Kaiserludi . Btw, if MasterClient disconnects, will the next MasterClient know that the previous MasterClient disconnected so that he can raise an event?