Sending parameters to client in Photon v3
Options
Hi there,
We couldn't send any parameters to the client with SendOperationResponse.
Here is the code we use when generating the response. I think we make mistakes when using SetParameter method. I tried some other implementations but no difference. I get 0 parameters in the client side. In v2 I think hastables are used but in v3 dictionary should be used to set parameters
We couldn't send any parameters to the client with SendOperationResponse.
Here is the code we use when generating the response. I think we make mistakes when using SetParameter method. I tried some other implementations but no difference. I get 0 parameters in the client side. In v2 I think hastables are used but in v3 dictionary should be used to set parameters
private void HandleKeywordRequest(OperationRequest operationRequest, SendParameters sendParameters) { Dictionary<byte, string> opParams = new Dictionary<byte, string>(); opParams.Add((byte)100, "hello"); OperationResponse or = new OperationResponse(); or.SetParameters(opParams); this.SendOperationResponse(or, sendParameters); }
0
Comments
-
Hi, you forgot to set the OperationCode of the response that you are sending.0
-
Oh, I just noticed that you use "SetParameters" - the parameter is a "contract" object, not a dictionary.
use "or.Parameters = opParams" instead.
You could also define a class like thisclass TestResponse { [DataMember(Code = 100)] public string Hello {get;set;} }
and thenvar contract = new TestResponse { Hello = "hello" }; var response = new OperationResponse(request.OperationCode, contract); this.SendOperationResponse(response, sendParameters);
orvar contract = new TestResponse { Hello = "hello" }; var response = new OperationResponse(); response.OperationCode = request.OperationCode; response.SetParameters(contract); this.SendOperationResponse(response, sendParameters);
0 -
How about:
var response = new OperationResponse(100); response.Parameters = new Dictionary<byte, object>{{1,"hello"}}; SendOperationResponse(response, sendParameters);
If you want to go the contract-free route?0 -
Yep, looks good.0