PUN API
Options
hi.i want to know that is there any way of handling clients connection to the server???
for example we have a method (connectUsingSettings) in PUN that connect the client to master server with a App version.so anyone can connect to server with his own app version.is it possible to handle these settings in the server to force clients to connect in a same App ID???
for creating my own client sdk what API shoudl i use????
for example we have a method (connectUsingSettings) in PUN that connect the client to master server with a App version.so anyone can connect to server with his own app version.is it possible to handle these settings in the server to force clients to connect in a same App ID???
for creating my own client sdk what API shoudl i use????
0
Comments
-
photonnetwork.connectusingsetting(string gameversion)
gameVersion This client's version number. Users are separated from each other by gameversion (which allows you to make breaking changes).
what does it make separated???0 -
hmmmmm, i think it doesn't matter what version client using.because in photon Premise this feature is disabled right??according to this page
https://doc.photonengine.com/en-us/realtime/current/getting-started/onpremises-or-saas#differences_table0 -
i'm a little bit confusing.
enum ClientState
Detailed connection / networking peer state. PUN implements a loadbalancing and authentication workflow "behind the scenes", so some states will automatically advance to some follow up state. Those states are commented with "(will-change)".
"behind the scenes"????
what is that mean???
in photonnetwork.connectToMaster() when i followed the source i figured out it that photonnetwork class use a method in networkingPeer class.and the networkingPeer is inherited from LoadbalancingPeer class and LoadbalancingPeer class inherited from PhotonPeer class.well , till here everything make sense to me.but in netwrokingPeer class that it use base.Connect() method (PhotonPeer.connect()) to connect Client to Master,nothing will happen till 2 space line later :public bool Connect(string serverAddress, ServerConnection type) { if (PhotonHandler.AppQuits) { Debug.LogWarning("Ignoring Connect() because app gets closed. If this is an error, check PhotonHandler.AppQuits."); return false; } if (this.State == ClientState.Disconnecting) { Debug.LogError("Connect() failed. Can't connect while disconnecting (still). Current state: " + PhotonNetwork.connectionStateDetailed); return false; } this.cachedServerType = type; this.cachedServerAddress = serverAddress; this.cachedApplicationName = string.Empty; this.SetupProtocol(type); // connect might fail, if the DNS name can't be resolved or if no network connection is available bool connecting = base.Connect(serverAddress, "", this.TokenForInit); /////// Region the MAGIC thing that i cant understand it if (connecting) { switch (type) { case ServerConnection.NameServer: State = ClientState.ConnectingToNameServer; break; case ServerConnection.MasterServer: State = ClientState.ConnectingToMasterserver; break; case ServerConnection.GameServer: State = ClientState.ConnectingToGameserver; break; } } /////// EndRegion the MAGIC thing that i cant understand it return connecting; }
and this is the magic code that i cant figure it out how does this piece of code make the connection and i can receive it from my server.believe me i made this code commented and nothing i would receive from my server.
to my question i want to implement some logic to not everybody can join the master.public void OnConnectClicked() { PhotonPeer peer = new PhotonPeer(_photon , ConnectionProtocol.Udp); if (_photon.initialize(peer, "127.0.0.1:5055", "LoadBalancing")) { Debug.Log("connected"); connected = true; } } public void OnConnectUsingSettingsClicked() { Debug.Log(PhotonNetwork.ConnectToMaster("127.0.0.1", 5055 , "LoadBalancing" , "1.0")); }
and the funny thing is this that when i use my own peer and use PUN peer (that use LoadbalancingPeer)
they both will connect to server.the only difference that i cant figure it out is that with PUN connection my Master server will authenticate the client and give him a UserID.and i don't know how does it work.i know it will do those authentication with ClientState Enums.but what is that magic came from???What's Next?
0 -
how does this piece of code work????
public LoadBalancingPeer(ConnectionProtocol protocolType) : base(protocolType)
{
Debug.Log("on LoadBalancingPeer constructor");
// this does not require a Listener, so:
// make sure to set this.Listener before using a peer!
}
i never attach this Loadbalancing peer class or any c# script that inherited from this class.
to be clear my scene is empty.there is nothing in it.but when i start the game it will return this debug.log message.how??????how this PUN work???????????????????????0 -
when i use PUN custom authentication my server wont redirect peer to OnCustomAuthenticationRequest method.insted it use HandleAuthenticateRequest method.what is the problem??
public void OnConnectUsingSettingsClicked() { PhotonNetwork.AuthValues = new AuthenticationValues(); PhotonNetwork.AuthValues.AuthType = CustomAuthenticationType.Custom; PhotonNetwork.AuthValues.UserId = "hasan"; PhotonNetwork.AuthValues.AddAuthParameter("user", "Aidin"); PhotonNetwork.AuthValues.AddAuthParameter("pass", "123456"); PhotonNetwork.ConnectUsingSettings("1.1"); }
0 -
in one case i could make an CustomAuthentication
2018-04-02 17:11:13,676 [11] DEBUG Photon.SocketServer.Rpc.Peer - set operation handler to Photon.LoadBalancing.Master.OperationHandler.OperationHandlerAuthenticating, was Photon.LoadBalancing.Master.OperationHandler.OperationHandlerInitial - peer id 1 2018-04-02 17:11:13,695 [15] DEBUG Photon.Common.Authentication.CustomAuthHandler - Authenticating client 1 - custom authentication type: 0 2018-04-02 17:11:14,055 [12] DEBUG Photon.SocketServer.Net.HttpRequestQueue - ProcessResponseConnecting: Url:'http://photon.webscript.io/auth-demo?secret=customauthsecret&user=Aidin&pass=123456', Request WebStatus: NameResolutionFailure, Response , Exception: System.Net.WebException: The remote name could not be resolved: 'photon.webscript.io' at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at Photon.SocketServer.Net.AsyncHttpRequest.GetResponseCallBack(IAsyncResult ar) in h:\svncontent\photon-socketserver-sdk_cloud\src\Photon.SocketServer\Net\AsyncHttpRequest.cs:line 346 2018-04-02 17:11:14,080 [12] DEBUG Photon.Common.Authentication.CustomAuthentication.ClientAuthenticationQueue - Custom authentication error: uri=http://photon.webscript.io/auth-demo?secret=customauthsecret&user=Aidin&pass=123456, status=Faulted, msg=The remote name could not be resolved: 'photon.webscript.io' 2018-04-02 17:11:14,100 [12] DEBUG Photon.Common.Authentication.CustomAuthHandler - Authenticate client finished: conId=1, result=Error 2018-04-02 17:11:14,119 [12] DEBUG Photon.LoadBalancing.MasterServer.MasterClientPeer - Client custom authentication failed: appId=LoadBalancing, result=CustomAuthenticationFailed, msg=Custom authentication service error: Error 2018-04-02 17:11:14,138 [12] DEBUG Photon.SocketServer.PeerBase - SentOpResponse: Peer=T:MasterClientPeer,ConnId:1,ip:127.0.0.1:63864, opCode=230, return=32755(Custom authentication service error: Error), ChannelId=0 result=Ok size=52 bytes 2018-04-02 17:11:14,158 [12] DEBUG Photon.SocketServer.Rpc.Peer - set operation handler to Photon.LoadBalancing.Master.OperationHandler.OperationHandlerInitial, was Photon.LoadBalancing.Master.OperationHandler.OperationHandlerAuthenticating - peer id 1
and i dont know what did i changed that now i cant receive CustomAuthentication from server.
i dont want to use web protocols for checking the clients authentication.i just want to receive the data while connecting to master server then i can handle those authentication from photon server.
0 -
well i enabled the customAuth settings from Photon.LoadBalancing.dll.config and now i can get those messages again from customAuthentications.but why using Web???why not using the Photon server to connect to a Database for checking the data's????i cant figure out this.can u explain it to me???
tnx... i'm waiting0 -
For the public Photon Cloud using Custom Authentication via Webhooks is the only way to do authentication. This is a standard procedure to integrate different systems. If you are asking for a reason, this is simply because we do not host any customer user/player DBs.
Using Photon Server, you can of course adjust the server code to directly query a database as you like.1 -
how many authenticationHandler exist in loadbalancing Application????i can see some of them.but i want to be sure that my clients wont use some unknown authentications.and how to disable multiplayer login from one IPaddress?0