The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

RaiseEvent failing. Event can't be sent!

FGk
2017-08-17 16:43:10

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
2017-08-18 03:05:33

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
2017-08-18 10:43:25

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
2017-08-18 11:21:56

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
2017-08-18 12:36:36

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
2017-08-18 12:41:41

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
2017-08-18 12:49:09

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
2017-08-18 12:58:04

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?

Back to top