Noob question: OperationResult() || OnOperationResponse() ?

Options
by0logic1
by0logic1
edited November 2011 in DotNet
Hey there,
I'm a new Photon user, figuring my way around true networking development; don't expect too much from me. Still, I've setup a LiteLobby application and test-modify it until I feel at ease with the Properties, Events and Operations.

I'm now stuck on one of the last (first step of) milestone which is implementing custom operations and fetching result. Perhaps someone in here will be kind enough to point me the right direction.

I'm just trying a simple test and log everything so I get an idea of what gets called when, where, etc. Basically I start with my client calling, GUI.cs:
Dictionary<byte, object>() args = new Dictionary<byte, object>(){ { (byte)78, "I'm hungry, feed me." } };
bool result = peer.OpCustom((byte)111, args, true);    // return : true - no invocID?

Server follows with this, LitePeer.OnOperationRequest() :
Dictionary<byte, object>() args = new Dictionary<byte, object> { { (byte)79, "No, you wait for dinner." } };
OperationResponse response = new OperationResponse((byte)111, args);
this.SendOperationResponse(response, sendParameters);

Now the base client didn't implement the OperationResult method. I added one but it never - ever - get called. Though I'll receive this from the OnOperationResponse(), client-side:
case (byte)111:
    Debug.Log("Just received feedback from server.");
    Debug.Log(operationResponse);    //return : OperationResponse 111: ReturnCode: -1
    Debug.Log(operationResponse.Parameters.Count.ToString());    //return : 0
    Debug.Log(operationResponse.Parameters[(byte)79].ToString());    //return : NullReferenceException(of course)
    return;

Finally, I believe it is just I who is confusing a left with a right somewhere along the way yet at the same time; I think the documentation might be slightly outdated (?) or perhaprs that -1 ReturnCode means something went wrong? Any hints on what I should do to correctly implement request->handling->result will be very appreciated!

Thanks a lot,
Bi0z Dwizar

Comments

  • Kaiserludi
    Kaiserludi admin
    edited November 2011
    Options
    Hi.
    The Photon 1/2 client API used OperationResult() as callback for operation responses.
    It has been replaced by onOperationResponse() with Photon 3.
  • by0logic1
    Options
    Hey, thanks for the feedback. That clears the confusion about which method should handle the result. I really appreciate the hard work you guys put into this but I'd like to point out the online docs is pretty misleading about Photon3 as the pages claim they are updated.

    I'm still unable to collect the result parameters. OnOperationResponse() does receive the callback but the Parameters arguments always shows empty, aka 0 Count. I'm pretty much using the exact code shown on my previous post which is pretty much the same as proposed/advised here : http://forum.exitgames.com/viewtopic.php?f=6&t=869 . I'd rather avoid the contract way, if possible.

    Printing the operationResponse also gives a ReturnCode: -1 . I still have to go and figure what that means exactly.

    Any help appreciated, once I figure this out I should be ready to start rolling!
  • Kaiserludi
    Options
    A returnCode != 0 means an error and a negative returnCode indicates that the error has been reported by the core, not by the application.
    In most cases the debug message gives additional information about the kind of the error, but I have to admit, that "NullReferenceException" can mean a lot.
    Sorry, but it looks, like you have to wait for a colleague of me, who is more into the serverSide, to help out.
    Just one more comment about what you have wrote in the startpost: invocationIDs have been recently thrown out of the API. Are they still in the Photon 3 doc on the website? Really looks, like we have to go over that doc again.
  • by0logic1
    Options
    Yeah, both pages about Operations with Photon3 refers to Photon2, I believe.
    http://doc.exitgames.com/v3/photonclient/callingoperations
    http://doc.exitgames.com/liteandlitelobbyaddon/addingoperations

    The NullReferenceException in itself isn't a surprise as I'm trying to access a collection that reported a 0 KeyValue Count the line above. What's bothering is why the Parameters dictionary always arrives empty. Also the ReturnCode -1 , which is hard for me to track as its a short and not an enum.

    I'm still stuck on this so I'd really appreciate if someone could help me figure it out. Should I bump the thread every now and then or can I expect someone to show up in the next few days?

    By the way, I'm using a modified version of the Unity PhotonChat example, which extends the LiteLobby. The server had no changes aside the new OperationCode and the new OnOperationRequest switch case. Its running locally.

    Thanks again.