Separating client/server code (Unity)

Mazza101
edited March 2011 in Photon Server
I'm trying to separate the code on the Unity BootCamp project into 2 parts, the client and server codes.

The reason for this is I want to be able to have 1 main server and then X number of clients, I would use the MMO software for this but the project is a Third person shooter so I believe it would be much more work and surely this isn't a difficult task.

I don't want the clients to be able to make a server of any sort, but I am finding it difficult to understand the way Photon works.

Can anyone be of assistance as to which classes are associated with which part?

For example is the LiteLobby.cs and LitePeer.cs classes server based or client based or both?

Comments

  • I'm having a real tough time understanding the code used in the BootCamp example... it seems very unclear and disorganised.
  • Everything that's in the client is client related and the server is a separate project, called Lite Lobby.

    Did you read the Developer Network on the bootcamp?
    http://developer.exitgames.com/bootcampmultiplayerdemo
    The code is just one way to achieve multiplayer in something as complex as the bootcamp demo. We also worked with an existing sample here and modified it into multiplayer, so some design decisions are influenced by existing structures. You can always simply start fresh. Examples are here:
    http://developer.exitgames.com/quicksta ... worldpart1

    After reading it, can you please ask more specific questions? Otherwise it's very difficult to give specific help.
  • Okay, I've spent a long time looking over the code and I understand quite a bit of it now.

    Are there any plans to make an example of this game with the data stored on the server? That's what I'm trying to do now.

    I'm having a few problems sending operations to and from the server, it just doesn't seem to be working.
    This is the code in LiteGame.cs in ExecuteOperation() (Server)
    case OperationCodes.Test:
                            {
                                OperationResponse response = new OperationResponse(operationRequest, 0,
                                "Don't understand, what are you saying?");
                                //  peer.SendOperationResponse(response);
                                peer.PublishOperationResponse(response);
                                return;
                            }
    

    This is code run shortly after connecting to the server: (client)
    GameInstance.peer.OpCustom(108, new Hashtable { { 100, "Hello World" } }, true);
    

    and this is the code in OperationResult() in Game.cs (Client)
    if (returnCode == 108)
                {
                    this.DebugReturn("Message Recieved FROM ASDDDDDDDSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSss");
                }
    


    Have I made any obvious errors there?
  • the key 100 needs to be of type byte when submitting it
    GameInstance.peer.OpCustom(108, new Hashtable { { (byte)100, "Hello World" } }, true);
    
    I assume code 108 is the value of OperationCodes.Test?
    Also, before this operation will arrive in the LiteGame you need to forward it there, see method OperationRequestDispatcher.DispatchOperationRequest - this is where all requests arrive at first.