which one I should use opCustom or opRaise?

Options
Paresh
edited October 2011 in Native
hi,
I want to send action of one actor to server & at server side to perform some operation over it & then pass it to all the other actors in room.

I tried using opCustom from client side but I found that it not replying to all the actors in a room but only to sender itself. Is it the way it works or i am missing something? :?

it will be great if you can mention pros & cons of both opCustom & opRaise.

Thanks,
Paresh

Comments

  • Kaiserludi
    Options
    Hi.

    opCustom is a Photon core layer functionality:
    "Send any kind of operation to the server, then let the server do something with it". What to do with this operation is completely up to you and has to be implemented by yourself in the applications layer.

    opRaiseEvent on the other side is a Lite functionality.
    Lite simply is an application, which is sitting on top of Photon like any other serverside high-level functionality, including your own server-side applications for implementing for example game-specific behavior.
    Lite is implementing it's operations simply on top of Photon's opCustom functionality () thats not only true for raiseEvent, but same for join or leave, etc., as Photon itself doesn't even know the concept of rooms, which is implemented on Lite-level) and raiseEvent is implemented in a way, that if the server side Lite application gets an operation with the raiseEvent operationCode, it will not do any operation-specific server logic on it, but instead just copying the payload of the operation into an event and send that event out to either all actors in the same room as the sender of the operation, except the sender itself (in case, no receiver-list has been specified), or to the specified receivers-list.

    So, if you want to just send some data to other clients, but not trigger any game-specific serverside logic on that data, then you can use the raiseEvent operation, which already provides this functionality.
    If however you want to trigger some serverside logic, then you have to write your own custom operation, using opCustom.

    Of course, your server can't know, what to do on receiving you custom operation, unless you tell it, so it will just respond with an unknown operation error to the sending client.
    You have to implement the operation not only on client-, but also on serverside:
    - define, if the server should respond to the client at all and if, what data to send in response.
    - define, what to do with the data on the server-side, for examplecheck against cheating, validate the data with a physics engine, store some info in a database, etc.
    - define, if the operation should trigger any event and if so, which data should be in the events, when and how often should they be sent and who should receive them