Disconnecting from Photon?
The whole answer can be found below.
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).
Disconnecting from Photon?
SaravanaKumar
2013-11-11 10:20:15
Hi,
I created Room and entered into it. Pressing back button should disconnect. But, still its in Connection.
So, I can't able to create room again.
Here is my scenario in Workers Demo example:
First I created an Room and waiting for someone to enters into the room.
After one client entered into my room. I give Return to lobby to come into Menu (Create or Join Group)
From there if i again try create room. It shows an error like below.
I know that its not yet disconnected.
Can you tell me how to disconnect when i press back button from InGame.? :?:
createGame failed, client stays on masterserver: OperationResponse 227: ReturnCode: 32766 (A game with the specified id already exist.). Parameters: {}. UnityEngine.Debug:LogError(Object) PhotonHandler:DebugReturn(DebugLevel, String) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:170) NetworkingPeer:DebugReturn(DebugLevel, String) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:802) NetworkingPeer:OnOperationResponse(OperationResponse) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:952) ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[]) ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands() ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands() PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:76)
Comments
You can use PhotonNetworking.Leave() to not disconnect but leave the room. Or you can use PhotonNetworking.Disconnect(), which will require a PhotonNetwork.ConnectUsingSettings() again.
SaravanaKumar
2013-11-29 09:12:11
I disconnected from the room and PhotonNetwork successfully.
public void OnPhotonPlayerDisconnected(PhotonPlayer player) function will be called after player disconnected/leave from Room.
But, In My scenario After one player is disconnecs/leaves the room means the list need to updated. I will call one function which refreshes
playerlist. But it contains RPC Functions. So, I can't able to call inside OnPhotonPlayerDisconnected()[Calling inside the
OnPhotonPlayerDisconnected will leads to crash Unity].
Where could i call to refresh to playerlist. So, that others can know how many players are active/available.
Which player list? Photon Unity Networking has a built-in player list but that is of course kept up to date for you. You don't have to manipulate that one. If you built your own, I can't really help, cause I don't know the code and what you do. In worst case, make sure the next Update() loop will call some method to clean your player list.
Back to top