public final class WebApi
extends java.lang.Object
STOP! Do not modify this file. Changes will be overwritten during official grading.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
API_BASE
The URL at which the server is hosted.
|
static java.lang.String |
WEBSOCKET_BASE
The URL at which the webserver socket is hosted.
|
Modifier and Type | Method and Description |
---|---|
static void |
connectWebSocket(java.lang.String url,
java.util.function.Consumer<com.google.gson.JsonObject> dataListener,
java.util.function.Consumer<com.neovisionaries.ws.client.WebSocket> onCreatedListener,
java.lang.Runnable connectionLostListener,
java.util.function.Consumer<java.lang.Throwable> errorListener)
Connects to a websocket.
|
static void |
startRequest(android.content.Context context,
java.lang.String url,
int method,
com.google.gson.JsonElement body,
com.android.volley.Response.Listener<com.google.gson.JsonObject> listener,
com.android.volley.Response.ErrorListener errorListener)
Starts a network request with a JSON object as the payload.
|
static void |
startRequest(android.content.Context context,
java.lang.String url,
com.android.volley.Response.Listener<com.google.gson.JsonObject> listener,
com.android.volley.Response.ErrorListener errorListener)
Starts an HTTP GET request.
|
public static final java.lang.String API_BASE
public static final java.lang.String WEBSOCKET_BASE
public static void connectWebSocket(java.lang.String url, java.util.function.Consumer<com.google.gson.JsonObject> dataListener, java.util.function.Consumer<com.neovisionaries.ws.client.WebSocket> onCreatedListener, java.lang.Runnable connectionLostListener, java.util.function.Consumer<java.lang.Throwable> errorListener)
url
- the websocket endpointdataListener
- receiver for data messagesonCreatedListener
- callback to run with the websocket when it is createdconnectionLostListener
- callback to run if the connection is losterrorListener
- callback to run if an error occurs during the initial connectionpublic static void startRequest(android.content.Context context, java.lang.String url, int method, com.google.gson.JsonElement body, com.android.volley.Response.Listener<com.google.gson.JsonObject> listener, com.android.volley.Response.ErrorListener errorListener)
context
- an Android contexturl
- the URL to contactmethod
- the HTTP method (GET or POST)body
- the JSON object to include in the bodylistener
- callback to run with response dataerrorListener
- callback to run if an error occurspublic static void startRequest(android.content.Context context, java.lang.String url, com.android.volley.Response.Listener<com.google.gson.JsonObject> listener, com.android.volley.Response.ErrorListener errorListener)
context
- an Android contexturl
- the URL to contactlistener
- callback to run with response dataerrorListener
- callback to run if an error occurs