On joining a room, I get an error when I try to set my voice groups.

edited January 13 in Photon Voice

When I join a room, I am added to a 'zone' which has it's own voice group - to ensure each zones chat is private.
To handle this, on moving to the zone this code is called:
if (updatedUser == myUser)
            byte[] groupToRemove = voiceGroup;
            if (zoneLocations.Contains(newLocation))
                byte index = Convert.ToByte(zoneLocations.IndexOf(newLocation) + 1);
                voiceGroup = new byte[] { index };
                PhotonVoiceNetwork.Instance.Client.OpChangeGroups(groupToRemove,  voiceGroup);
            PhotonVoiceNetwork.Instance.PrimaryRecorder.InterestGroup = voiceGroup[0];

However, on entering the room I am getting this error:
"Operation ChangeGroups (248) not allowed on current server (NameServer)"

I am passing in a default value of '7' as a byte (it's what voiceGroup is set to initially).
Every time I change zone after this, the above code works perfectly and I can only hear those in my zone.

I've tried searching for what causes this, especially considering I am definitely in a photon room when the above code is called.

Any ideas?

Best Answer


  • Hi @ShadowToast,

    Photon Voice integration with PUN works with two clients: PUN client and Voice client.
    The way the integration works is that the PUN client first joins a PUN room THEN the Voice client joins a voice room.

    So I think what's happening here is that you are trying to set interest groups for the Voice client too early, you try to set interest groups for the voice client after the PUN client joined a room BUT before the Voice client finishes joining a room.

    So you need to wait until
    PhotonVoiceNetwork.Instance.ClientState == ClientState.Joined
  • edited January 14
    @JohnTube So this looked like exactly what I needed.
    I am having some issues though.

    The setting:
    PhotonVoiceNetwork.Instance.AutoConnectAndJoin = true;
    Doesn't seem to work, as when I join a room the following happens:
    public override void OnJoinedRoom()
        private IEnumerator SetVoiceSettingsToDefault()
                yield return new WaitForEndOfFrame();
            } while (PhotonVoiceNetwork.Instance.ClientState != ClientState.Joined);
            UpdateAudioByLocation(defaultLocation, myUser);
            yield return null;
    The first time I join a room it works fine, but when I leave to the lobby and join a new room it gets stuck in the coroutine do loop as the client state is never 'Joined'.

    I tried calling connect and join for the photon voice network before starting the coroutine to wait for the connection. It mostly failed to connect entirely.

    Edit 1:
    I imagine this happens due to the client state not being connected to the master server when I attempt to connect.
    When I disconnect from a room, return to the lobby and join a new room the voice client state never changes from disconnected.
    Do I have to instigate a 'connect to master, connect to room' each time?
    Edit 2:
    I checked in the above coroutine whether or not the client state is disconnected, and if it is to call connect with settings (as auto connect doesn't work), the client state changes as follows:
    First time I join:

    Joining a new room:
    ConnectedToMaster (Which is odd, as this state is shown as depreciated)

    When it gets to here it stalls, and I attempt to connect and join.
    No dice:
    [Voice.PhotonVoiceNetwork] Connecting to server failed.
  • Hey @JohnTube,

    This seems to have fixed it, brilliant!
    If I have any issues, I'll make a new post.
    As far as I'm concerned this is exactly what I needed.

    I look forward to the next version!

Sign In or Register to comment.