How to Setproperties in Lite?

Options
billTCP
edited June 2012 in DotNet
Hi guys, do you know how to use the SetProperties in the Lite server? I connect to the Lite server, and sending "raiseEvent" message well, the client received the response from the server. The code of sending raiseEvent is:
peer.OpCustom((byte)LiteOpCode.RaiseEvent, opParams, true);
where opParams is a Hashtable with the value of
opParams[LiteOpKey.Data] = evData;
But when I want to send the SetProperties operation, by changing the first parameter of opCustom:
peer.OpCustom((byte)LiteOpCode.SetProperties, opParams, true);
Then the operation failed in the server, and the client received the error message:
********error message*********
invocID=3
---OperationResult: NOK - SetProperties(93)
 ->returnCode=-1 DebugString=Missing value 12 (SetPropertiesOperation.Properties
)

**********interface to handle the OperationResult*************
public void OperationResult(byte opCode, int returnCode, System.Collections.Hashtable returnValues, short invocID)
        {

            Console.WriteLine("invocID={0}", invocID);

            if (returnCode == 0)
                Console.WriteLine("\n---OperationResult: OK - " + (LiteOpCode)opCode + "(" + opCode + ")");
            else
            {
                Console.WriteLine("\n---OperationResult: NOK - " + (LiteOpCode)opCode + "(" + opCode + ")\n ->returnCode=" + returnCode + " DebugString=" + returnValues[(byte)LiteOpKey.DebugString]);
                return;
            }
......
}


So how should I do to send the SetProperties message? I traced in the lite server, it looks like the operation does not pass the validate:
In Lite server of LiteGame.cs:

case OperationCodes.SetProperties:
{
	var setPropertiesOperation = new SetPropertiesOperation(operationRequest);

	Log.WarnFormat("inside setProperties ={0}", setPropertiesOperation.IsValid); // here it prints false

	if (peer.ValidateOperation(setPropertiesOperation) == false)
	{
		return; // It returns here and send the client with error message
	}

	this.HandleSetPropertiesOperation(peer, setPropertiesOperation);
	break;
}

How does it validate? And what's the data structure of opParams when sending the SetProperties message?

Thanks~~

Comments

  • Tobias
    Options
    You don't have to trace server-side for that. Just have a look at the definition of the operation requests.
    The server logic tries to map your request to a specific Type (by operation code). The classes deriving from Operation (e.g. SetPropertiesRequest.cs and RaiseEventRequest.cs) define which parameters are required, optional and the parameter codes.
    If you just rename the operation, the parameters of raiseEvent won't map to those of setProperties. You are calling another method without adjusting the parameters.

    Have a look at SetPropertiesRequest or use LitePeer.SetProperties.
  • billTCP
    Options
    thanks
  • Tobias wrote:
    Have a look at SetPropertiesRequest or use LitePeer.SetProperties.
    Where can I find them?
  • dreamora
    Options
    The later is a function of LitePeer which you are using on the client or extending for your purpose, if you use the Lite application