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

ShadowToast
edited January 2020 in Photon Voice
Hello,

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 Answers

  • ShadowToast
    Answer ✓
    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!

    Thanks.

Answers

  • JohnTube
    JohnTube ✭✭✭✭✭
    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
    
  • ShadowToast
    edited January 2020
    @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()
        {
            StartCoroutine(SetVoiceSettingsToDefault());        
        }
    
        private IEnumerator SetVoiceSettingsToDefault()
        {
            do
            {
                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:
    ConnectedToNameServer,
    ConnectingToMasterserver,
    Authenticating,
    ConnectingToGameserver,
    Joining,
    Joined

    Joining a new room:
    ConnectedToNameServer,
    ConnectingToMasterserver,
    Authenticating,
    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.
    
  • ShadowToast
    Answer ✓
    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!

    Thanks.
  • Last time this came up was in 2020 and @JohnTube said it was fixed just not released yet. Has that release gone out?

    My chat works just fine in global mode when working on interest group 0 but when i go to change it is when i get the 248 error. The link to the fix is not there.


    for code im using this

    void setTeam(byte teamNumber)  {

          if (view.IsMine) {

            PhotonVoiceNetwork.Instance.Client.OpChangeGroups(null, new byte[1] { teamNumber });

            FindObjectOfType<Photon.Voice.Unity.Recorder>().InterestGroup = teamNumber;  

    }

    }

  • What is the 248 error?

    What was fixed in 2020? Maybe you have a link to a thread or other clue?

  • Michael_Watkins
    edited August 2022

    This thread. The original poster had the same problem as me

    "Operation ChangeGroups (248) not allowed on current server (NameServer)"

  • This error means that the voice client is not joined to a room when you are trying to change interest group with OpChangeGroups() call

  • ah ha. that makes sense. Do i need to use some sort of callback that will let me know it has joined so that i can then go ahead and change the interest group?

  • never mind i kinda fudged it and now it works


    void Update()

      {

        if (!hasJoined && PhotonVoiceNetwork.Instance.ClientState.ToString() == "Joined")

        {

          hasJoined = true;

          battleManager.PlayerM.setVoiceGroup(battleManager.PlayerM.teamName);

        }

      }