Identify Connection

Options
Nachtmahr
edited March 2013 in Photon Server
Hi Community,

I want to Connect Multible Subservers and differnt Clients (UnityClient, KiClient) to my MasterServer. The Connections itself is no Problem at all but I have serious Problems to Identify the Peers!

example:

In the Masterservers CreatePeer(Initrequest r) method I want to create Different Peers (Like GameserverPeer, UnityPeer, LoginserverPeer) but I cant find a solution to Identify the connection. Is there a way to send Data along with the initrequest?

The remote IP alone is not enough to identify the Connection. And the remote IP is always random.

Any suggestions?

Comments

  • nope you cannot send additional data along with init request. Instead you can have different type of peers connect to different ports.

    For ex, let's say your clients uses UDP and your SubServers uses TCP
    SubServers connect to: Port 4520(Default Photon TCP port for Server-to-Server communication)
    Unity Clients connects to: Port 5055(UDP)
    KiClient connects to: Port 5056(UDP)
    .Net Client connects to: Port 5057(UDP)

    you can add as many ports as you want(not true :P)
    Inside the Master check the local port(Not Remote Port!!) and create appropriate peers. And make sure you set-up port forwarding in for your router firewall to allow such ports. Photon enables 5055 by default(UDP) and 4520(TCP). Hope this helps :)
  • SubServers connect to: Port 4520(Default Photon TCP port for Server-to-Server communication)

    Ok this fact helps me a lot to generaly identify subserver connections! I have not tested the local ports of different clients, but it sound promissing.

    Well seems like I need to do a operation request "RegisterServerType" and somehow assign different Handlers to them. Still dont like the fact that I need to put everything trough one peer Class for Subservers but I think I can handle that.

    Thank you very much zeppelinisgod!
  • Depending on your game you can re-design your server. If you are building the server for a single game Master-Client approach is a better one(from my experience, managing the server is less hassle). However, if your master will be hosting multiple games, a LoadBalancing approach would be much optimal. You can have your client connect to the master and request what type of game to play then the master sends the game's connection address and port then the client can connect(Check out the LoadBalancing source which comes with photon by default)

    For the register operation, you definitely need to register the server so the master knows that it is a valid server and can forward client messages. And you don't really need to handle everything inside one peer. You can create for ex, Player class inside the sub server and identify each player by a unique id assigned by the master at connect(you can reference player across other servers using the id). Then you can forward messages unique to the player and let him handle it, in my game I just create a new PoolFiber for each player and queue each player's messages on their thread, this minimizes the calculation the sub server's thread has to handle and prevent message clogging.
  • Thanks for the great explanation, zeppelinisgod! :)

    Nachtmahr: you might also want to check out the "Loadbalancing" solution that is part of the Photon Server SDK - especially the classes where the server-to-server communication is handled ("LoadBalancing.GameServer.OutgoingMasterServerPeer" and "LoadBalancing.MasterServer.GameServer.IncomingGameServerPeer" are a good starting point) - we are doing something similar there, like registering gameservers (=subservers), recognizing client types by their local ports etc. http://doc.exitgames.com/photon-server/LoadBalancing/ gives an overview how it works.

    (http://doc.exitgames.com/photon-server/LoadBalancing/ )