WebRPC Response

Options
Hello!

I'm sending a webrpc to my web server which have a php script setup to handle it this way:
<?php
header('Content-Type: application/json');
$request = file_get_contents('php://input');
$decoded = json_decode($request);
$array = null;

if($decoded === null) {
    $req_dump = print_r( "Failed to decode the JSON Object\n", true );
    $fp = file_put_contents('/var/log/gameserv/log2.log', $req_dump,FILE_APPEND );
}


$array = array(
    "ResultCode" => 0,
    "Message" => "Found post!"
);

$out = json_encode($array);
echo $out;

$req_dump = print_r( $request, true );
$fp = file_put_contents('/var/log/gameserv/log.log', $req_dump,FILE_APPEND );
$req_dump = print_r( $out, true );
$fp = file_put_contents('/var/log/gameserv/log2.log', $req_dump,FILE_APPEND );
?>

On my unity client, i have this setup:

public void createCharacter() {
		Dictionary<string, object> _test = new Dictionary<string, object>();
		_test.Add ("UserId", 1);
		_test.Add ("eyebrow", 1);
		_test.Add ("ear", 1);

		Debug.Log ("test " + _test);
		PhotonNetwork.WebRpc ("webrpc.php?webhook=1", _test);
		PhotonNetworkingMessage.OnWebRpcResponse;
	}

	void OnWebRpcResponse (OperationResponse operationResponse) {
		Debug.Log ("RECEIVING SOMETHING!");
		if (operationResponse.ReturnCode != 0) {
			Debug.Log ("WebRPC operation failed: " + operationResponse.ToStringFull ());
			return;
		}
		WebRpcResponse webRpcResponse = new WebRpcResponse (operationResponse);
		if (webRpcResponse.ReturnCode != 0) {
			Debug.Log ("WebRPC " + webRpcResponse.DebugMessage);
			return;
		}
		Dictionary<string, object> parameters = webRpcResponse.Parameters;
		foreach (KeyValuePair <string,object> pair in parameters) {
			Debug.Log(string.Format("KEY {0} / VALUE: {1}", pair.Key, pair.Value));
		}
	}

Im connecting with customauth to my server and can get an anwser back and all i can see the data trought the echo of login but i cannot get any anwser back from the webrpc. On server side i see i receive the _test object im sending and all just cant get any anser back. Tryed with Postman and everything is fine. So im guessing my void onWebRpcResponse is not correct but cannot find any documentation that clearly show how this work. I'm using Pun v2.

Anyone could help me figure out? :)

Comments

This discussion has been closed.