How to full stop and free Photon, total disconnect?

Options
Hi.
My game is very simple, it have 5 levels.
Player play level, reach score till it dies. After die level reloading for clear all and start again.
Each level player can start in "online mode", where player can play with enother player, who dies faster, thouse loose.

Networking is simplest ever:
1. Connect to Photon
2. JoinOrCreate room
3. Wait for another player ready
4. Play
5. Show win or loose info
6. Exit scene and total disconnect from any room\server etc (im using Disconnect() before load new scene).

On any error or connection lost just return to menu.

1st play works great, but after someone dies and reloading scene running same code and IPunCallbacks.OnConnectedToMaster not calling.

So best way is full stop Photon and reconnect again.
How to stop it, and can use again same way as first time?

Comments

  • Alekxs
    Options
    Some more info, on second try to connect PUN fall in
    ConnectedToNameServer state and Reconnect() do nothing :(
  • Alekxs
    Options
    Found temporal solution.
    On scene restart PUN still in disconnecting state, so lets wait till it be done before connecting.

    IEnumerator Start () // just after scene load
    {
    if (PhotonNetwork.connectionStateDetailed == ClientState.Disconnecting)
    {
    print("wait for previous disconnect end");
    while (PhotonNetwork.connectionStateDetailed == ClientState.Disconnecting)
    yield return null;
    }

    ....... usual Photon initialization