How to change Photon Voice Region
Options
mlaibow
✭
I am trying to change the region of the PhotonVoiceNetwork client.
I can change the region of PUN, no problem. I disconnect and the reconnect PUN with a new region code, then join or create a room on the new region master server.
With PhotonVoiceNetwork set to automatically connect, join, and disconnect, it will disconnect and reconnect when I switch the PUN region, but it always connects to the best region.
I would like to be able to switch the PhotonVoiceNetwork region when the PUN region is changed. I should be able to do this manually.
I have tried turning off the auto connect and disconnect in Photon Voice and then running:
So then I try to join a room with:
What step am I missing to manually connect Photon Voice to a selected region and then join a room?
I am using Unity 2018.3 and PUN 2 and Photon Voice 2. I have everything else with PUN and Photon Voice working great, until I switch regions on PUN and I can't do the same with Photon Voice.
Thanks!
I can change the region of PUN, no problem. I disconnect and the reconnect PUN with a new region code, then join or create a room on the new region master server.
With PhotonVoiceNetwork set to automatically connect, join, and disconnect, it will disconnect and reconnect when I switch the PUN region, but it always connects to the best region.
I would like to be able to switch the PhotonVoiceNetwork region when the PUN region is changed. I should be able to do this manually.
I have tried turning off the auto connect and disconnect in Photon Voice and then running:
AppSettings appS = new AppSettings(); appS.AppIdVoice = PhotonNetwork.PhotonServerSettings.AppSettings.AppIdVoice; appS.AppIdRealtime = PhotonNetwork.PhotonServerSettings.AppSettings.AppIdRealtime; appS.UseNameServer = true; appS.FixedRegion = PhotonNetwork.CloudRegion; photonVoiceNetwork.ConnectUsingSettings(appS);Which works, and Photon Voice Network will connect to master server with the new region code and the client state becomes ConnectedToMasterserver.
So then I try to join a room with:
EnterRoomParams erps = new EnterRoomParams(); erps.RoomName = PhotonNetwork.CurrentRoom.Name; photonVoiceNetwork.Client.OpJoinRoom(erps);This causes the state to go to Joining, but immediately back to ConnectedToMasterServer without any information even in log level ALL. It never gets to Joined.
What step am I missing to manually connect Photon Voice to a selected region and then join a room?
I am using Unity 2018.3 and PUN 2 and Photon Voice 2. I have everything else with PUN and Photon Voice working great, until I switch regions on PUN and I can't do the same with Photon Voice.
Thanks!
0
Comments
-
Hi @mlaibow,
Thank you for choosing Photon!
You are describing two issues:
1. How to set Photon Voice region
2. Photon Voice can't join a room
Regarding 1, make sureappS.FixedRegion = PhotonNetwork.CloudRegion;
is not null or empty before callingphotonVoiceNetwork.ConnectUsingSettings(appS);
. Once connected in Photon Voice, log the region and server address fromPhotonVoiceNetwork.Client
.
Regarding 2, where did you increase the log level? You should increase it for PhotonVoiceNetwork and maybe from the AppSettings itself.
For both 1 and 2, you can use SupportLogger by enabling it from PhotonVoiceNetwork.0 -
I do not believe I have a problem with 1 - setting voice region.
I am able to use the above code to set the AppSettings to a fixed region and connect.
The problem is with 2 - Photon Voice can't join a room.
I have increased the log level on both the PhotonVoiceNetwork and the Photon Network Settings, and I have enabled support logger.
I can confirm that the region is changing and the PHotonVoiceNetwork is connected to master.
When I run the OpJoinRoom as above, first I see:
[PhotonVoiceController.PhotonVoiceNetwork] OnVoiceStateChanged from ConnectedToMasterserver to Joining
as expected, but then it immediately does this:
[PhotonVoiceController.PhotonVoiceNetwork] OnVoiceStateChanged from Joining to ConnectedToMasterserver
and it goes right back and does not join the room.
maybe i am not setting up the EnterRoomParams properly?
Thanks!0 -
I seem to have it working now.
It turned out to be the fact that I was using the same room name for Voice as I was for PUN, and then I was callingOpJoinRoom
instead ofOpJoinOrCreateRoom
.
The code that works is:public override void OnJoinedRoom() { print("OnJoinedRoom " + PhotonNetwork.CurrentRoom.Name); AppSettings appS = new AppSettings(); appS.AppIdVoice = PhotonNetwork.PhotonServerSettings.AppSettings.AppIdVoice; appS.AppIdRealtime = PhotonNetwork.PhotonServerSettings.AppSettings.AppIdRealtime; appS.UseNameServer = true; appS.FixedRegion = PhotonNetwork.CloudRegion; photonVoiceNetwork.ConnectUsingSettings(appS); } private void VoiceClient_StateChanged(ClientState arg1, ClientState arg2) { //Debug.Log("Voice state changed from " + arg1.ToString() + " to " + arg2.ToString() + " region " + photonVoiceNetwork.Client.CloudRegion); if(arg2 == ClientState.ConnectedToMasterserver) { string voiceRoomName = string.Format("{0}{1}", PhotonNetwork.CurrentRoom.Name, PhotonVoiceNetwork.VoiceRoomNameSuffix); Photon.Realtime.RoomOptions voiceRoomOptions = new Photon.Realtime.RoomOptions { IsVisible = false }; PhotonVoiceNetwork.Instance.Client.OpJoinOrCreateRoom(new EnterRoomParams { RoomName = voiceRoomName, RoomOptions = voiceRoomOptions }); } else if (arg2 == ClientState.Joined) { RoomVoiceObject = PhotonNetwork.Instantiate(RoomVoicePrefab.name, Vector3.zero, Quaternion.identity, (byte)0); } }
I basically broke up the code in the FollowPUN function in the PhotonVoiceNetwork script and call connect for voice with the new region in the settings after PUN joins a room, then when Voice is connected JoinOrCreate the voice room
0 -
For your use case, here is something you can try without changing the code and you can use custom room names.
In PhotonVoiceNetwork.cs, lines 360-369 replace:private void FollowPun() { if (applicationIsQuitting) { return; } if (PhotonNetwork.NetworkClientState == this.ClientState) { if (PhotonNetwork.NetworkClientState == ClientState.Joined) {
with:private void FollowPun() { if (applicationIsQuitting) { return; } if (PhotonNetwork.NetworkClientState == this.ClientState) { if (PhotonNetwork.NetworkClientState == ClientState.Joined && this.AutoConnectAndJoin) {
0