How can I check connecting client on correctness?
Options
crutch12
✭
Hi,
I have photon server on my self-hosted server. I try to make some "protection" from clients who are trying to connect to my server from different client.
For example: I have "Game 1" (right) and "Game 2" (bad). All operations have to work only from client "Game 1". If someone connect from "Game 2" (and join the same room) this will break all operations in "Game 1" and create a lot of exceptions.
I checked this: I started my own game (connected and joined in room) after I started game from PUN examples and joined the same room and got a lot of exceptions. (In my game all rooms have to be with property Visible = true, so don't want to hide rooms, I want to don't let client with "Game 2" do smth on my photon server)
How can I mind "Game 2" connect and join rooms on my server? Mb using unique id of game or smth like that:
But I think that the best solution - just kick from server any clients who connected from different game.
Thanks
I have photon server on my self-hosted server. I try to make some "protection" from clients who are trying to connect to my server from different client.
For example: I have "Game 1" (right) and "Game 2" (bad). All operations have to work only from client "Game 1". If someone connect from "Game 2" (and join the same room) this will break all operations in "Game 1" and create a lot of exceptions.
I checked this: I started my own game (connected and joined in room) after I started game from PUN examples and joined the same room and got a lot of exceptions. (In my game all rooms have to be with property Visible = true, so don't want to hide rooms, I want to don't let client with "Game 2" do smth on my photon server)
How can I mind "Game 2" connect and join rooms on my server? Mb using unique id of game or smth like that:
if (ConnectedClientGameId != TrueGameId) { Kick(client); }Or mb I can set some property inside room to clients which doesn't know this property couldn't join this room.
But I think that the best solution - just kick from server any clients who connected from different game.
Thanks
0
Best Answers
-
if you mean that for instance 'Game 1' is Chess and 'Game 2' is a pocker game, that yes. it is better to kick. During authentication you should be able to set AppId. in case of Photon Cloud you set there some GUID. but in your case you may set some name or guid too. your master server may compare this values and reject wrong users
this will help a little, but if someone wants to connect he will take this id and use it. so, you should be prepared for this cases anyways5 -
there is MasterClientPeer.cs this is peer class for client connection on MasterServer
it has methods HandleAuthenticate...
look for GameClientPeer.HanldeAuthenticateOperation5
Answers
-
if you mean that for instance 'Game 1' is Chess and 'Game 2' is a pocker game, that yes. it is better to kick. During authentication you should be able to set AppId. in case of Photon Cloud you set there some GUID. but in your case you may set some name or guid too. your master server may compare this values and reject wrong users
this will help a little, but if someone wants to connect he will take this id and use it. so, you should be prepared for this cases anyways5 -
Thx for answer, but I don't know the main thing: how can I do this? Where in OnPremise photon server should I open some class and add some checking there? I don't know structure of photon serverchvetsov said:but in your case you may set some name or guid too. your master server may compare this values and reject wrong users
So I don't know how to realize this checking.0 -
there is MasterClientPeer.cs this is peer class for client connection on MasterServer
it has methods HandleAuthenticate...
look for GameClientPeer.HanldeAuthenticateOperation5 -
Thanks a lot! I'll check this and share results in this topic.0
-
Done. This is too easy
1) Open \src-server\Loadbalancing\LoadBalancing.sln (using visual studio)
2) Find and open in Solution Explorer LoadBalancing\MasterServer\MasterClientPeer.cs
3) Find method "public OperationResponse HandleAuthenticate(OperationRequest operationRequest, SendParameters sendParameters)
"
4) Paste inside phrase like this:if (authenticateRequest.ApplicationId != "SOME SPECIAL ID 1234567890") { //instead you can use AppID which generated by Photon Realtime Dashboard in your account return OperationHandlerBase.HandleInvalidOperation(authenticateRequest, log); }
5) Click Run in VS. This will recompile dll files. Wait while full starting and click Stop. Now use this tutorial to export new dll files in server: https://doc.photonengine.com/en-us/onpremise/current/operations/server-config
6) After exporting open unity and open PhotonServerSettings and set AppID: "SOME SPECIAL ID 1234567890" (instead you can use AppID which generated by Photon Realtime Dashboard in your account)
This has to be look like this:
That's all, thx chvetsov.
1