PhotonNetwork.Disconnect C# (CSharp) Method

Disconnect() public static method

Makes this client disconnect from the photon server, a process that leaves any room and calls OnDisconnectedFromPhoton on completition.
When the client is connected, the server is being informed that this client disconnects. This speeds up leave/disconnect messages for players in the same room as you (otherwise the server would timeout this client's connection). When used in offlineMode, the state-change and event-call OnDisconnectedFromPhoton are immediate. Offline mode is set to false as well. Once disconnected, the client can connect again. Use ConnectUsingSettings.
public static Disconnect ( ) : void
return void
    public static void Disconnect()
    {
        if (offlineMode)
        {
            offlineMode = false;
            networkingPeer.State = PeerState.Disconnecting;
            networkingPeer.OnStatusChanged(StatusCode.Disconnect);
            return;
        }

        if (networkingPeer == null)
        {
            return; // Surpress error when quitting playmode in the editor
        }

        networkingPeer.Disconnect();
    }

Usage Example

Ejemplo n.º 1
0
 public void LeaveRoom()
 {
     PhotonNetwork.Disconnect();
     SceneManager.LoadSceneAsync("Lobby");
 }
All Usage Examples Of PhotonNetwork::Disconnect