Photon Voice autoconnects when creating an Offline Room

crystalpug
edited May 2018 in Photon Voice
I have an issue which I believe might be a bug in the Photon Voice autoconnection logic. I have a game with both online and offline modes, where for the offline mode I use the PhotonNetwork.offlineMode flag. There are 3 steps that cause the issue.

1. Connect to Photon server using PhotonNetwork.ConnectToRegion and match into a room.
2. Leave the room, PhotonNetwork.Disconnect () and go into PhotonNetwork.offlineMode, then create a new room using PhotonNetwork.CreateRoom (). At this point, Photon Voice automatically connects to the server, even though we are in offlineMode (note that this occurs even if step 1 is skipped, and it connects to the default region "eu").
3. Leave the offline room, then attempt to reconnect to PUN server using PhotonNetwork.ConnectToRegion. On the first attempt, PhotonNetwork.connectionState goes from Disconnected to Connected, but there is no OnConnectedToMaster callback, and PhotonNetwork.connected and PhotonNetwork.connectedAndReady get stuck in a false state. On subsequent attempts to connect, the warning displays "ConnectToRegion() failed. Can only connect while in state 'Disconnected'. Current state: Connected".

The core of the issue is that in Step 3:

if (PhotonNetwork.connectedAndReady)  // Always returns false
  JoinOrCreateRoom ();
else
  PhotonNetwork.ConnectToRegion (...);  // No OnConnectedToMaster callback to then join or create room
Should Photon Voice not connect to server when creating an offline room? Are the connection state vars incorrect due to Photon Voice being connected but PUN not being connected?

I have followed the guide for using offline mode, are my steps correct for it?

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited May 2018
    Hi @crystalpug,

    Thank you for your report!

    What you are seeing and describing are two different bugs:

    1. A bug in auto connect in Photon Voice: the workaround is to disable "Auto Connect" and handle Photon Voice connection manually yourself when you join a room in PUN call PhotonVoiceNetwork.Connect(). We will release a fix in the next update.
    2. A bug in the offline mode switching in PUN. I believe there is a fix already for this shared on the forum but not released yet.

    Sorry for the inconvenience and thank you for your understanding and patience.
  • JohnTube
    JohnTube ✭✭✭✭✭
    @crystalpug

    Photon Voice 1.15 has been submitted to the store, it will go live in few hours.
    Update and let us know if it fixes the issues you mentioned.
  • @JohnTube Thanks John I will check it out
  • @JohnTube Thanks the 1.15 fix for Autoconnect worked. Any idea of when the fix for the offline mode switching fix will be available? Or have a link for it on the forums so I can make the fix?
  • JohnTube
    JohnTube ✭✭✭✭✭
    The fix for the offline mode switching is already part of Photon Voice 1.5 see "Assets\Photon Unity Networking\changelog.txt" for the version history of the special PUN version included in Photon Voice.
  • I still want my game to connect to photon voice chat when in offline mode, how do I do this now?
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited June 2018
    Hi @SniperED007,

    You need to manually connect and join room from voice client.

    You have these two methods for connection handling:
    PhotonVoiceNetwork.Connect(authValues, nickname);
    PhotonVoiceNetwork.Disconnect();
    When the voice client is connected to Master Server (
    PhotonVoiceNetwork.ClientState == LoadBalancing.ClientState.ConnectedToMasterserver) you can join a "voice room" using:
    PhotonVoiceNetwork.Client.OpJoinRoom
    Once joined (
    PhotonVoiceNetwork.ClientState == LoadBalancing.ClientState.Joined) you can do the "voice prefab" instantiation or manually handle recording/transmission and reception/playback.

    You can get notified about voice client state changes using:
    PhotonVoiceNetwork.Client.OnStateChangeAction