Connecting subservers

Options
hmehta410
edited July 2013 in Photon Server
How do I connect the physically different servers together. I connect clients by creating a class the implements IPhotonPeerListener which have the OnEvent() and OnOperationResponse() methods. I can also then create a PhotonPeer (which needs the IPhotonPeerListener in the constructor) and call Connect() to communicate with the server.

My subservers have a class that extends ServerPeerBase that have the OnEvent() and OnOperationResponse() methods but then I can't create a PhotonPeer to call Connect() on the server.

So my question is how do I Connect() form one subserver to another?

Comments

  • On the Subserver, call ApplicationBase.ConnectToServerTcp().
    When the connection is established, CreateServerPeer() is called on the SubServer FROM which you initiated the connection. In CreateServerPeer, you should create an instance of your class that extends ServerPeerBase.

    The server TO which the connection is established can not distinguish if the connection is from a "real" client or from another server, so the normal CreatePeer() is called. However, you can use a different port for incoming S2S-connections and check initRequest.LocalPort, if you need to handle incoming S2S connections differently from incoming client connections.

    Examples for this can be found in the "Loadbalancing" project of the Photon Server SDK.
  • Thanks ConnectToServerTcp() was exactly what I was looking for :D
  • I noticed when looking in ApplicationBase method calls there is one called CreateServerPeer() that is a callback for ApplicationBase.ConnectToServer(). Is this just another way that the server the connection is being made to can distinguish between players and other servers besides distinguishing by ports? Or should it not be used for some reason?
  • "CreateServerPeer" is the callback for outbound connections. Let's say you establish a connection from Server A to Server B. This is what happens / is called on each server:

    On Server A ("outbound"):
    => ConnectToServerTcp()
    => CreateServerPeer() as callback when connection was established

    On Server B ("inbound"):
    => CreatePeer() when incoming connection is established (no way to distinguish between s2s / client connections, despite different ports)