Class TeaNetwork

java.lang.Object
nl.colorize.multimedialib.renderer.teavm.TeaNetwork
All Implemented Interfaces:
Network

public class TeaNetwork extends Object implements Network
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.

Peer-to-peer connections are supported using WebRTC. This is mostly implemented in JavaScript using the PeerJS library.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    nl.colorize.util.Subject<nl.colorize.util.http.URLResponse>
    get(String url, nl.colorize.util.http.Headers headers)
    Sends a HTTP GET request to the specified URL.
    boolean
    Returns true if this renderer supports peer-to-peer connections on the current platform.
    Opens a peer-to-peer connection.
    nl.colorize.util.Subject<nl.colorize.util.http.URLResponse>
    post(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 Details

    • TeaNetwork

      public TeaNetwork()
  • Method Details

    • get

      public nl.colorize.util.Subject<nl.colorize.util.http.URLResponse> get(String url, nl.colorize.util.http.Headers headers)
      Description copied from interface: Network
      Sends a HTTP GET request to the specified URL. The request will be performed asyncrhonously, the returned Subject can be used to subscribe to the response.
      Specified by:
      get in interface Network
    • post

      public nl.colorize.util.Subject<nl.colorize.util.http.URLResponse> post(String url, nl.colorize.util.http.Headers headers, nl.colorize.util.http.PostData data)
      Description copied from interface: Network
      Sends a HTTP POST request to the specified URL. The request will be performed asyncrhonously, the returned Subject can be used to subscribe to the response.
      Specified by:
      post in interface Network
    • openPeerConnection

      public PeerConnection openPeerConnection()
      Description copied from interface: Network
      Opens a peer-to-peer connection. The protocol used for the connection depends on both the renderer and the current platform.
      Specified by:
      openPeerConnection in interface Network
    • isPeerToPeerSupported

      public boolean isPeerToPeerSupported()
      Description copied from interface: Network
      Returns true if this renderer supports peer-to-peer connections on the current platform. If this method returns false, trying to open peer-to-peer connections using Network.openPeerConnection() will result in an exception.
      Specified by:
      isPeerToPeerSupported in interface Network