This class is a sample of how to implement WebRPCs calling & callbacks. More...

Public Member Functions | |
void | OnWebRpcResponse (OperationResponse response) |
Called when the response to a WebRPC is available. See LoadBalancingClient.OpWebRpc. More... | |
void | WebRpcExampleCall () |
Static Public Member Functions | |
static void | WebRpcCall (string methodName, object parameters=null, bool sendAuthCookieIfAny=false) |
Public Attributes | |
const string | GetGameListWebRpcMethodName = "GetGameList" |
example of WebRPC method name, add yours as enum or constants to avoid typos and have them in one place More... | |
Detailed Description
This class is a sample of how to implement WebRPCs calling & callbacks.
Member Function Documentation
◆ OnWebRpcResponse()
void Photon.Pun.Demo.WebRpcImplementationExample.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; } }
Implements Photon.Realtime.IWebRpcCallback.
◆ WebRpcCall()
|
static |
◆ WebRpcExampleCall()
void Photon.Pun.Demo.WebRpcImplementationExample.WebRpcExampleCall | ( | ) |
Member Data Documentation
◆ GetGameListWebRpcMethodName
const string Photon.Pun.Demo.WebRpcImplementationExample.GetGameListWebRpcMethodName = "GetGameList" |
example of WebRPC method name, add yours as enum or constants to avoid typos and have them in one place
The documentation for this class was generated from the following file:
- 3rd-Party/Photon/PhotonUnityNetworking/Demos/WebRpcImplementationExample.cs