Lost on this Photon Server

Options
ZZyrex
edited August 2014 in Photon Server
I would like some help understanding photon server, as I'm a bit lost at the moment. I have read through the docs, and although it says how to add operations on the server-side it is mentioned that this is not an elegant solution? (Mentioned here: http://doc.exitgames.com/en/onpremise/current/tutorials/adding-operations)

What would be an elegant solution, and how would I add multiple operations to the server-side? Is it as simple as each case represents a specific operation, and all I need to do is program that case individually? or is there some sort of registry which stores operation class files which I have to manually alter to state that I want this and that to be loaded?

As for the Client side, I think I understand this from just looking through the server demos (WinGrid etc), is the basic concept if an event occurs, call all functions you deem necessary? Eg: Player moves, so send a request for operationMovement? (Just a guess) or am I completely off? I'm not too sure on all the default features for this as there is no API documentation for this as far as I know.

Also, what is the difference between Photon Server (V3) and Photon OnPremise(V4) apart from the obvious (One being a newer version) but I can tell that V4 is already taking a step in the right direction with a API directory. Is it a good idea to start developing with V4? Is it much different than v3?

Sorry for all the questions, but when I'm starting out on an API I prefer to know how things work, before seeing everything compiled as a complete example as I find this to be confusing and somewhat over-whelming with a lack of understanding it just feels like I am making assumptions every where :lol:

Comments

  • Any advice any one?
  • If you continue to read down the page it explains the elegant version. I believe their goal was to first explain how it works, get a version working for you, and then explain how to implement it properly. It's rather complicated, but a decent system. My only beef is with the usage of bytes. If I'm not mistaken, that leaves me with less than 256 operations. Photon already uses some 20 or so. 230 is a lot, so I may never have an issue, but seems like just using an 'int' wouldn't increase bandwidth much and would allow for infinite operations.

    Anywho, bit of a tangent there. Continue reading and examine Server Side, Advanced Version carefully, and extend that code. :) Good luck.
  • I would also like to add that the Exit Games site is a little bloated, maybe? There's a lot of pages and words that don't always seem like they need to exist. The best thing to do, I found, is to literally read ALL of it. Just spend a couple days reading every freaking word. There's some gems hidden in there, and sufficient info to get you well on your way.
  • Kaiserludi
    Options
    My only beef is with the usage of bytes. If I'm not mistaken, that leaves me with less than 256 operations. Photon already uses some 20 or so. 230 is a lot, so I may never have an issue, but seems like just using an 'int' wouldn't increase bandwidth much and would allow for infinite operations.
    That would add 3 bytes for every operation, which doesn't sound much, but such things sum up and it's simply not needed. The biggest type that one even should consider for this would be a short, but even that would be overkill and unneeded traffic for 99.9% of the applications out there. For those maybe 0.1% (if at all) of the applications that really need more than 2 different operations , there is a really simple solution. Just add you own secondary operation code in the payload of the message:

    [code2=cpp]switch(opCode)
    {
    case 1:
    switch(secondOpCode)
    {
    case 1:
    break;
    // and so on
    }
    break;
    // and so on
    }[/code2]
  • Thanks guys I think I got it now, To add serverside code we have to make a specific case for a specific operation and then call for that specific case on the client side with the following code:
    peer.OpCustom(1, parameter, true);
    
    where one represents the case number right? I would like some clarification on working with client side code.

    When working on the clientside, what does photon have pre-built? Such as for players, if I want to have players move about do I have to create a class which manages how I want my player entity to work (I can assume this is the case) but does photon have any player specific properties which I don't know about? I'm assuming the way it works is like the following:
    • Player A presses right key
    • Client acknowledges right key press and sends a OperationRequest
    • Server browses through the Operation cases until it locates the one requested
    • Operation is run, and it determines whether the move is valid
    • Server sends the response, true or false? or can I return a string/int? (1, 2, 3, 4, 5 etc) (Should I return co-ordinates or just a simple boolean? which is better?)
    • Client interprets message and moves players avatar on screen?

    is this how it's meant to go?