Download

Need help with Photon C++ API and opCustom() method

Hi there,

as someone might know I’m trying to implement Photon C++ API with UE4. I’m almost done but as I’m not a very well programmer regarding c++ I have one last obstacle to get rid of. The API defines a method named opCustom takin in an OperationRequest. This operation request takes in an operation code (nByte) and a second parameter OperationRequestParameters. This is a dictionary<nByte, object). I know how to do this in C* but cannot get it working in C++. Is there anyone out there who can help me?

I’ve included the files of interest from the Photon API for reference.

In C+ it is done like this:


 var parameters = new Dictionary<byte, object>();

        parameters.Add((byte) ClientParameterCode.SubOperationCode, ClientOperationCode.Login);
        parameters.Add((byte) ClientParameterCode.UserName, username);
        parameters.Add((byte) ClientParameterCode.Password, password);
        var request = new OperationRequest {OperationCode = (byte) ClientOperationCode.Login, Parameters = parameters};

Thanks in advance.

Hi Serphimera.

Assuming that username and password are strings, the following code should do what you want:



OperationRequestParameters op;
op.put(ClientParameterCode.SubOperationCode, ValueObject<nByte>(ClientOperationCode.Login));
op.put(ClientParameterCode.UserName, ValueObject<JString>(username));
op.put(ClientParameterCode.Password, ValueObject<JString>(password));

OperationRequest request(ClientOperationCode.Login, op);