Photon .NET Client API 4.1.4.8

Public Member Functions | List of all members
Photon.Realtime.IWebRpcCallback Interface Reference

Interface for "WebRpc" callbacks for the Realtime Api. Currently includes only responses for Web RPCs. More...

Inherited by Photon.Realtime.WebRpcCallbacksContainer.

Public Member Functions

void OnWebRpcResponse (OperationResponse response)
 Called when the response to a WebRPC is available. See LoadBalancingClient.OpWebRpc. More...
 

Detailed Description

Interface for "WebRpc" callbacks for the Realtime Api. Currently includes only responses for Web RPCs.

Classes that implement this interface must be registered to get callbacks for various situations.

To register for callbacks, call LoadBalancingClient.AddCallbackTarget and pass the class implementing this interface To stop getting callbacks, call LoadBalancingClient.RemoveCallbackTarget and pass the class implementing this interface

Member Function Documentation

◆ OnWebRpcResponse()

void Photon.Realtime.IWebRpcCallback.OnWebRpcResponse ( OperationResponse  response)

Called when the response to a WebRPC is available. See LoadBalancingClient.OpWebRpc.

Important: The response.ReturnCode is 0 if Photon was able to reach your web-service.
The content of the response is what your web-service sent. You can create a WebRpcResponse from it.
Example: WebRpcResponse webResponse = new WebRpcResponse(operationResponse);

Please note: Class OperationResponse is in a namespace which needs to be "used":
using ExitGames.Client.Photon; // includes OperationResponse (and other classes)

public void OnWebRpcResponse(OperationResponse response) { Debug.LogFormat("WebRPC operation response {0}", response.ToStringFull()); switch (response.ReturnCode) { case ErrorCode.Ok: WebRpcResponse webRpcResponse = new WebRpcResponse(response); Debug.LogFormat("Parsed WebRPC response {0}", response.ToStringFull()); if (string.IsNullOrEmpty(webRpcResponse.Name)) { Debug.LogError("Unexpected: WebRPC response did not contain WebRPC method name"); } if (webRpcResponse.ResultCode == 0) // success { switch (webRpcResponse.Name) { // todo: add your code here case GetGameListWebRpcMethodName: // example // ... break; } } else if (webRpcResponse.ResultCode == -1) { Debug.LogErrorFormat("Web server did not return ResultCode for WebRPC method=\"{0}", Message={1}", webRpcResponse.Name, webRpcResponse.Message); } else { Debug.LogErrorFormat("Web server returned ResultCode={0} for WebRPC method=\"{1}", Message={2}", webRpcResponse.ResultCode, webRpcResponse.Name, webRpcResponse.Message); } break; case ErrorCode.ExternalHttpCallFailed: // web service unreachable Debug.LogErrorFormat("WebRPC call failed as request could not be sent to the server. {0}", response.DebugMessage); break; case ErrorCode.HttpLimitReached: // too many WebRPCs in a short period of time // the debug message should contain the limit exceeded Debug.LogErrorFormat("WebRPCs rate limit exceeded: {0}", response.DebugMessage); break; case ErrorCode.InvalidOperation: // WebRPC not configured at all OR not configured properly OR trying to send on name server if (PhotonNetwork.Server == ServerConnection.NameServer) { Debug.LogErrorFormat("WebRPC not supported on NameServer. {0}", response.DebugMessage); } else { Debug.LogErrorFormat("WebRPC not properly configured or not configured at all. {0}", response.DebugMessage); } break; default: // other unknown error, unexpected Debug.LogErrorFormat("Unexpected error, {0} {1}", response.ReturnCode, response.DebugMessage); break; } }


The documentation for this interface was generated from the following file: