Class Rest
Interface class used for communicating with the REST API on the server.
Namespace: PlayUR.Core
Assembly: PlayUR.dll
Syntax
public class Rest
Methods
| Improve this Doc View SourceEnqueueGet(string, Dictionary<string, string>, ServerCallback, bool)
Enqueues a GET command
Declaration
public static IEnumerator EnqueueGet(string page, Dictionary<string, string> form, Rest.ServerCallback callback, bool debugOutput = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | page | The endpoint we are requesting (relative to SERVER_URL/api/ |
| Dictionary<string, string> | form | Dictionary of key value pairs of information we want to send to the server. |
| Rest.ServerCallback | callback | Callback for handling response from the server. |
| bool | debugOutput | Optionally debug to the Unity console a bunch of information about how the request occurred. Use only when things are failing and we need to know what the server is directly saying. |
Returns
| Type | Description |
|---|---|
| IEnumerator |
Exceptions
| Type | Condition |
|---|---|
| ServerCommunicationException | thrown when the server is unreachable. |
EnqueuePost(string, Dictionary<string, string>, ServerCallback, bool, bool, bool)
Enqueues a POST command
Declaration
public static IEnumerator EnqueuePost(string page, Dictionary<string, string> form, Rest.ServerCallback callback = null, bool HTMLencode = false, bool debugOutput = false, bool storeFormInHistory = true)
Parameters
| Type | Name | Description |
|---|---|---|
| string | page | The endpoint we are requesting (relative to SERVER_URL/api/ |
| Dictionary<string, string> | form | Dictionary of key value pairs of information we want to send to the server. |
| Rest.ServerCallback | callback | Callback for handling response from the server. |
| bool | HTMLencode | |
| bool | debugOutput | Optionally debug to the Unity console a bunch of information about how the request occurred. Use only when things are failing and we need to know what the server is directly saying. |
| bool | storeFormInHistory | Stores the |
Returns
| Type | Description |
|---|---|
| IEnumerator |
EnqueuePut(string, int, Dictionary<string, string>, ServerCallback, bool, bool, bool)
Declaration
public static IEnumerator EnqueuePut(string page, int id, Dictionary<string, string> form, Rest.ServerCallback callback = null, bool HTMLencode = false, bool debugOutput = false, bool storeFormInHistory = true)
Parameters
| Type | Name | Description |
|---|---|---|
| string | page | |
| int | id | |
| Dictionary<string, string> | form | |
| Rest.ServerCallback | callback | |
| bool | HTMLencode | |
| bool | debugOutput | |
| bool | storeFormInHistory |
Returns
| Type | Description |
|---|---|
| IEnumerator |
Get(string, Dictionary<string, string>, ServerCallback, bool)
Standard HTTP GET request. Used for requesting information FROM the server. Has a callback for reading the response.
Declaration
public static IEnumerator Get(string page, Dictionary<string, string> form, Rest.ServerCallback callback, bool debugOutput = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | page | The endpoint we are requesting (relative to SERVER_URL/api/ |
| Dictionary<string, string> | form | Dictionary of key value pairs of information we want to send to the server. |
| Rest.ServerCallback | callback | Callback for handling response from the server. |
| bool | debugOutput | Optionally debug to the Unity console a bunch of information about how the request occurred. Use only when things are failing and we need to know what the server is directly saying. |
Returns
| Type | Description |
|---|---|
| IEnumerator |
Exceptions
| Type | Condition |
|---|---|
| ServerCommunicationException | thrown when the server is unreachable. |
GetFile(string, Dictionary<string, string>, ServerFileCallback, bool)
HTTP GET request for file end-points. Used for requesting information FROM the server. Has a callback for reading the response.
Declaration
public static IEnumerator GetFile(string page, Dictionary<string, string> form, Rest.ServerFileCallback callback, bool debugOutput = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | page | The endpoint we are requesting (relative to SERVER_URL/api/ |
| Dictionary<string, string> | form | Dictionary of key value pairs of information we want to send to the server. |
| Rest.ServerFileCallback | callback | Callback for handling response from the server. |
| bool | debugOutput | Optionally debug to the Unity console a bunch of information about how the request occurred. Use only when things are failing and we need to know what the server is directly saying. |
Returns
| Type | Description |
|---|---|
| IEnumerator |
Exceptions
| Type | Condition |
|---|---|
| ServerCommunicationException | thrown when the server is unreachable. |
GetWWWForm()
Helper function for building the form paramaters to the Rest class functions.
Use this because it will automatically populate with the userID (from PlayURPlugin.instance.user.id)
and gameID (from PlayURPlugin.instance.gameID).
Uses the terminology "WWWForm" because this class previously used UnityEngine.WWWForm objects.
Declaration
public static Dictionary<string, string> GetWWWForm()
Returns
| Type | Description |
|---|---|
| Dictionary<string, string> | A new Dictionary suitable for use as a |
GetWWWFormWithExperimentInfo()
Helper function for building the form paramaters to the Rest class functions.
Use this because it will automatically populate with the userID (from PlayURPlugin.instance.user.id)
and gameID (from PlayURPlugin.instance.gameID).
This version will also add in experimentID and experimentGroupID parameters, useful for some endpoints.
Uses the terminology "WWWForm" because this class previously used UnityEngine.WWWForm objects.
Declaration
public static Dictionary<string, string> GetWWWFormWithExperimentInfo()
Returns
| Type | Description |
|---|---|
| Dictionary<string, string> | A new Dictionary suitable for use as a |
Post(string, Dictionary<string, string>, ServerCallback, bool, bool)
Declaration
public static IEnumerator Post(string page, Dictionary<string, string> form, Rest.ServerCallback callback = null, bool HTMLencode = false, bool debugOutput = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | page | |
| Dictionary<string, string> | form | |
| Rest.ServerCallback | callback | |
| bool | HTMLencode | |
| bool | debugOutput |
Returns
| Type | Description |
|---|---|
| IEnumerator |
Put(string, int, Dictionary<string, string>, ServerCallback, bool)
Standard HTTP PUT request. Used for UPDATING data on the server. Has a callback for reading the response.
Declaration
public static IEnumerator Put(string page, int id, Dictionary<string, string> form, Rest.ServerCallback callback = null, bool debugOutput = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | page | The endpoint we are requesting (relative to SERVER_URL/api/ |
| int | id | id of the object we are updating data for. |
| Dictionary<string, string> | form | Dictionary of key value pairs of information we want to send to the server. |
| Rest.ServerCallback | callback | Callback for handling response from the server. |
| bool | debugOutput | Optionally debug to the Unity console a bunch of information about how the request occurred. Use only when things are failing and we need to know what the server is directly saying. |
Returns
| Type | Description |
|---|---|
| IEnumerator |
Exceptions
| Type | Condition |
|---|---|
| ServerCommunicationException | thrown when the server is unreachable. |