Class TeaInternetAccess
- java.lang.Object
-
- nl.colorize.multimedialib.renderer.teavm.TeaInternetAccess
-
- All Implemented Interfaces:
InternetAccess
public class TeaInternetAccess extends java.lang.Object implements InternetAccess
Sends HTTP requests by delegating them to JavaScript and sending them as AJAX requests. This does mean that any requests sent from the application must be allowed by the CORS (Cross Origin Resource Sharing) headers returned by the server.Web Sockets are also supported through the JavaScript web socket API, but this is only supported when running in browsers that include this API.
-
-
Constructor Summary
Constructors Constructor Description TeaInternetAccess()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WebSocketConnectionconnectWebSocket(java.lang.String uri)Connects to the web socket located at the specified URI.nl.colorize.util.Promise<java.lang.String>get(java.lang.String url, nl.colorize.util.http.Headers headers)Sends a HTTP GET request to the specified URL.booleanisWebSocketSupported()nl.colorize.util.Promise<java.lang.String>post(java.lang.String url, nl.colorize.util.http.Headers headers, nl.colorize.util.http.PostData data)Sends a HTTP POST request to the specified URL.
-
-
-
Method Detail
-
get
public nl.colorize.util.Promise<java.lang.String> get(java.lang.String url, nl.colorize.util.http.Headers headers)Description copied from interface:InternetAccessSends a HTTP GET request to the specified URL.- Specified by:
getin interfaceInternetAccess- Returns:
- A
Promisethat can be used to process the response once it has been received.
-
post
public nl.colorize.util.Promise<java.lang.String> post(java.lang.String url, nl.colorize.util.http.Headers headers, nl.colorize.util.http.PostData data)Description copied from interface:InternetAccessSends a HTTP POST request to the specified URL. The request body will be encoded using theapplication/x-www-form-urlencodedcontent type.- Specified by:
postin interfaceInternetAccess- Returns:
- A
Promisethat can be used to process the response once it has been received.
-
isWebSocketSupported
public boolean isWebSocketSupported()
- Specified by:
isWebSocketSupportedin interfaceInternetAccess
-
connectWebSocket
public WebSocketConnection connectWebSocket(java.lang.String uri)
Description copied from interface:InternetAccessConnects to the web socket located at the specified URI. Note that some platforms may only allow the secure web socket protocol (i.e."wss://").- Specified by:
connectWebSocketin interfaceInternetAccess
-
-