Class 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.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      WebSocketConnection connectWebSocket​(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.
      boolean isWebSocketSupported()  
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TeaInternetAccess

        public TeaInternetAccess()
    • 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: InternetAccess
        Sends a HTTP GET request to the specified URL.
        Specified by:
        get in interface InternetAccess
        Returns:
        A Promise that 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: InternetAccess
        Sends a HTTP POST request to the specified URL. The request body will be encoded using the application/x-www-form-urlencoded content type.
        Specified by:
        post in interface InternetAccess
        Returns:
        A Promise that can be used to process the response once it has been received.
      • connectWebSocket

        public WebSocketConnection connectWebSocket​(java.lang.String uri)
        Description copied from interface: InternetAccess
        Connects 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:
        connectWebSocket in interface InternetAccess