Get MasterServer Instance in the SubServer Class

sandolkakos
edited March 2012 in Photon Server
Hi guys,
At two months i started my game project using the Photon, and I'm really enjoying it, mainly because Christian (dragagon) Tutorial Series and too there is a community so active. Thanks to all.

This is my first post, because I always like to search for possible answers and try to solve before asking questions that already answered before.

I am following the tutorials Server2Server the Christian (dragagon):
http://www.youtube.com/playlist?list=PL ... ature=plcp
and now I'm caught in a situation that can not understand how to solve.

I need to know how can I get a "Unity3dPeer" within the Classes that inherit from "PhotonRequestHandler" or "SubServer". Example: "SubServerLoginHandler."

In other Classes, i can run this:
Unity3dPeer senderPeer;
masterServer.ConnectedClients.TryGetValue(new Guid((Byte[])operationResponse.Parameters[(byte)ParameterCode.UserId]), out senderPeer);
But SubServerLoginHandler dont know about "MasterServer Instance".

Is there anyone who knows the project structure of the Christian to help me, please.
Thank you in advance.

Comments

  • Hi,
    Not sure if this is what you want (the design could be either way) but I believe Christians design positioned the Master server as a request router. The subserver would simply response back to the Master Server which would then forward this response to the appropiate client using the code sample you showed.

    Why do you need access to the client peer in the sub server?

    Dan
  • Thanks for your attention "ddks".

    1.
    I have the SubServer Class = "AccountServer : SubServer". The AccountServer create the Instance of "SubServerAccountHandler : PhotonRequestHandler".

    Is in this "SubServerAccountHandler : PhotonRequestHandler" that i need use the MasterServer Instance to access the Unity3dPeer as i access from other Classes that know about the MasterServer Instance.
    I need access the Client Peer in the SubServer, because is in the SubServerAccountHandler that i handle the operations to Read/Write in the Database.
    2.
    Is a good idea use the IOperationHandler with Server2Server structure?
    or
    The correct way is use this structure that Christian is teaching with the SubServers to Handle Operations?

    Thanks to all.
  • Still not clear on why you want master server access inside the sub server. e.g. what I do is just pass a reference to the client connection to the sub server so that when the sub server has a response back to the master the client connection is there. I also R/W to the DB from the sub server e.g. Login then i pass the response back to the master (with the client-id) which then forwards the response back to the appropriate client.

    I have used various parts of Christians work as well but as you know his model is not complete, there are several parts/steps he is not addressing. In general when you start abstracting you create complexities sometimes the provided flexibility doesn't outweigh the downside.

    Dan
  • What dan is saying is correct. The login server passes a peerId. When you send a response back, the master server uses that peer id to identify which client to send the response to. From there, each sub server should contain all the data necessary to do its job. The only exceptions to this are when you need to pass data between sub servers which I began talking about in my last video with having handlers in the incommingSubServerPeer class so that you can intercept events and responses and make the appropriate calls.

    The message that you forward to the sub server should still contain all the data you need to read from the database. The only data I strip out is Peer ID and CharacterID so that the game messages can't be hacked.
  • Thanks for attention Dan and Christian.

    @Christian
    I have started from your "AegisBorn Server and Client" projects. Thanks for sharing the code and tutorials :)
    And look how my project is:
    http://universalgamesonline.com.br/unity3d/tcc/
    PS.: The 3d Model is not mine. It is only to tests, created by Polygonmaker.
    dragagon wrote:
    The only exceptions to this are when you need to pass data between sub servers which I began talking about in my last video with having handlers in the incommingSubServerPeer class so that you can intercept events and responses and make the appropriate calls.
    Yes, the only way that i found is intercepting the OperationResponses and EventDatas in the IncomingSubServerPeer before send to peer/peers.
    I thought i was in the wrong way, but then i was doing it correctly. :lol:
    dragagon wrote:
    The message that you forward to the sub server should still contain all the data you need to read from the database. The only data I strip out is Peer ID and CharacterID so that the game messages can't be hacked.
    Thanks for reinforcing this, cause i was already thinking of sending PlayerID (Info from DB) to control some things as character list, friend list, etc ...