How can I check connecting client on correctness?

Options
crutch12
crutch12
edited February 2017 in Photon Server
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:
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

Best Answers

Answers

  • crutch12
    Options
    chvetsov said:

    but in your case you may set some name or guid too. your master server may compare this values and reject wrong users

    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 server :(
    So I don't know how to realize this checking.
  • crutch12
    Options
    Thanks a lot! I'll check this and share results in this topic.
  • crutch12
    Options
    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.