Mandatory Responses

Options
miguel_hughes
edited March 2012 in DotNet
Hi all. I'm working on a game development which uses LitePeer on the client side to communicate with our photon server. We've have numerous cases in which we send a message that requires a response, without which we can't continue. This happens a lot during the initial load of the game.
We would like to have a way to detect if a response on a message hasn't come in.

Is there a built in way we can tell the lite peer to expect a response? This would be golden, but I've searched quite a bit and haven't found much. Otherwise, is there a demo we can take an example from to do this?

I've been thinking on how to implement it, but most of my solutions would require modifying a lot of our code... How would you recommend doing this, especially matching each response on each request. Is there an identifier on the messages we could use?

Thanks in advance.

Comments

  • Kaiserludi
    Options
    Hi.

    Just send these kind of operations with the reliable flag set to true and Photon will handle for you, that you always receive reliable commands, which have been sent in the same channel, in the same order, as they have been sent.
  • Hi Kaiserludi, thanks for your response.
    Are you sure that the reliable flag is meant to do what I'm asking? I'm already sending all my messages as reliable and I'm not seing the behaviour I described in my previous post. As far as I understand, sending a message as reliable guarantees that it will get from one end to the other, or a timeout will be triggered.
    I'm talking about a full roundtrip, from the client, to the server, and back to the client.
    If I do a request from my client, and my server method throws an exception, my client is not getting any response (of course), nor a timeout, it just waits.
  • dreamora
    Options
    Thats correct, you wouldn't get a response then but if the server throws an exception it also does no longer matter as the server will not longer operate correctly to my understanding.

    Whenever you get to see an exception on the server, you have at least one bug to fix (on the server side) but potentially more than one (parameter verification on client already prior sending) or at least to correct an incorrect / incomplete verification
  • Thanks dreamora, you confirm what I see. And I agree with you, if there's an exception on the server, there are bugs to fix. Still, we would like to detect the situation where server not responding to a particular operation, and take an appropiate action in the client. This will allow us to have less coupling between our server and our client, and to have a more robust client. So far, our client freezes and the game launch is blocked. Our intention is to switch the game to offline mode and allow the user to continue with gameplay.

    So, are there any demos and/or suggestions on how to go about this?
  • BenStahl
    Options
    An easy way would be to send an operation response with a specific result code back to the client if an exception occurs. So the client will be informed that the operation has failed without writing a lot of code.

    Here is an example how you could do this in the LitePeer implementation of the Lite project which comes with the server sdk:
    protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
    {
    	try
    	{
    	  switch ((OperationCode)operationRequest.OperationCode)
    		{
    			case OperationCode.Join:
    				this.HandleJoinOperation(operationRequest, sendParameters);
    				return;
    			
    			...
    		}
    	}
    	catch (Exception ex)
    	{
    		log.Error(ex);
    		var response = new OperationResponse { OperationCode = operationRequest.OperationCode, ReturnCode = -1 };
    		this.SendOperationResponse(response, sendParameters);
    	}
    }