AuthenticationValues, UserID, Photon Standalone Server
Options
I've seen some posts about setting the UserID in AuthValues when using the standalone server. I understand, I think, that each user connecting to the server needs a unique user ID. A couple of questions:
1. I'm not asking for user credentials in my application, users simply connect. I don't want to manage users at this point, so what is the best method for creating a user ID?
2. I see references to AuthValues in at least three clients: LoadBalancingPeer, LoadBalancingClient and PhotonNetwork. I know I need to set the UserID attribute before connecting to my serverf, but in which of these classes do I set this value. They all call a Connect() method as far as I can see, so where should it be set. I've searched the forums, but while I see some code snippets, each different, nowhere have I seen where to actually set the value so that it is available for any class calling Connect().
Any help? Much appreciated.
1. I'm not asking for user credentials in my application, users simply connect. I don't want to manage users at this point, so what is the best method for creating a user ID?
2. I see references to AuthValues in at least three clients: LoadBalancingPeer, LoadBalancingClient and PhotonNetwork. I know I need to set the UserID attribute before connecting to my serverf, but in which of these classes do I set this value. They all call a Connect() method as far as I can see, so where should it be set. I've searched the forums, but while I see some code snippets, each different, nowhere have I seen where to actually set the value so that it is available for any class calling Connect().
Any help? Much appreciated.
0
Comments
-
Hi @ar3k_g,
Sorry for the delay on this one.
I was on vacation.
1. generate a GUID client side.
2. I assume you use PUN. UsePhotonNetwork.AuthValues
.if (PhotonNetwork.AuthValues == null) { PhotonNetwork.AuthValues = new AuthenticationValues(System.Guid.NewGuid().ToString()); } else { PhotonNetwork.AuthValues.UserId = System.Guid.NewGuid().ToString(); } // connect
0 -
Ah, thank you. This is strictly for Photon Voice as that is what appears to be throwing the errors when more than one person enters multiplayer mode. My assumption is that this will fix that problem. I should have said this in the beginning, but I didn't, so shame on me.
Also, Guid insists that I use UnityEditor. I have no other way to call GUID. Does this sound right? It would be helpful to show everything in context, including the using directives. Just a thought. It would certainly helkp me now.0 -
Hi @ar3k_g,This is strictly for Photon VoiceWhat Photon Voice are you using? we have added this workaround to Photon Voice so you won't have to do it when connecting to self-hosted Photon Server?Also, Guid insists that I use UnityEditor. I have no other way to call GUID. Does this sound right?It should be
System.Guid
. I have updated the code above.0 -
That's interesting. We are using version v2.3. Would this workaround mean that we do not need to set a GUID at all? I said earlier that this is strictly for Photon Voice, but I must also consider PUN 2 Networking as well. Is a unique ID required there?0
-
Would this workaround mean that we do not need to set a GUID at all?The workaround was added in 2.2:FIXED: self-hosted Photon Server support (Photon Voice client UserId if no set, will use the same UserId as PUN if available or a new GUID)
if (string.IsNullOrEmpty(this.Client.UserId)) { this.Client.UserId = Guid.NewGuid().ToString(); #if PHOTON_UNITY_NETWORKING if (!string.IsNullOrEmpty(Pun.PhotonNetwork.NetworkingClient.UserId)) { this.Client.UserId = Pun.PhotonNetwork.NetworkingClient.UserId; } #endif }
Is a unique ID required there?Yes. So you probably need to use the code in PUN2 and the same UserID will be used in Voice per user.0 -
Thank you for the code, but as I am very new to this, I will probably always need some context. Such as, where does this code go? Class and method.0
-
I'm on 2.3, upgrading isn't an option at the moment. Ok, let me ask you a stupid question here: I am connecting the client (game client) to the standalone using ConnectUsingSettings, where in the settings I have specified, say, 10.0.0.1 via UDP on port 5055. Now, the stupid part: where do I set the connections for the voice settings?
Also, getting this when attempting to connect to voice room:
InvalidCastException: Specified cast is not valid.
Photon.Voice.VoiceClient.onVoiceEvent (System.Object content0, System.Int32 channelId, System.Int32 playerId, System.Int32 localPlayerId) (at Assets/DownloadedAssets/PhotonVoice/Photon/PhotonVoice/PhotonVoiceApi/Core/VoiceClient.cs:384)
Photon.Voice.LoadBalancingFrontend.onEventActionVoiceClient (ExitGames.Client.Photon.EventData ev) (at Assets/DownloadedAssets/PhotonVoice/Photon/PhotonVoice/PhotonVoiceApi/LoadBalancingFrontend.cs:287)
Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/DownloadedAssets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2581)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:633)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:545)
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1473)
Photon.Voice.Unity.VoiceConnection.FixedUpdate () (at Assets/DownloadedAssets/PhotonVoice/Photon/PhotonVoice/Code/VoiceConnection.cs:349)
0 -
Ok, I found the appropriate voice and recorder options. I had them set to follow PUN. Given that I am running against my own photon server, I unchecked this option and entered an IP address of my server, and a port. The protocol is UDP. I'm now having problems in that I cannot seem to create a Photon Voice Room. I get a million errors, stack trace below. Question: in my current photonserver.config file, I have two UDP listeners setup: master and game, which master on 5055 and game on 5056. My game connects to 5056, while voice connects to 5055. Does this sound right?
-----
Stack trace:
InvalidCastException: Specified cast is not valid.
Photon.Pun.PhotonNetwork.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/DownloadedAssets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:2033)
Photon.Realtime.LoadBalancingClient.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/DownloadedAssets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2581)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:633)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:545)
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1473)
Photon.Pun.PhotonHandler.FixedUpdate () (at Assets/DownloadedAssets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:130)
0