Interface Sender<INPUT>

  • Type Parameters:
    INPUT - This reqpresents the type that the Asynchronous Communications I/O is expecting to send. This class was originally developled to be used with WebSockets, and in that case, 'INPUT' type would be of type java.lang.String.

    NOTE: The contents of that String are in JSON format.
    All Known Implementing Classes:
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    public interface Sender<INPUT>
    This functional-interface should have the code/logic for sending an 'INPUT' message or request to the asynchronous I/O system/channel.

    The three classes, Script, Promise and Sender are designed to allow for the creation of 'Asynchronous Scripts' that may be executed and made to appear to be synchronous through the Promise.await() method.

    These three classes are made use of in the Browser Remote Debugging Protocol Package. Theoretically, they could be used by any asynchronous communication system.

    • Method Summary

      @FunctionalInterface (Lambda) Method
      Modifier and Type Method
      void send​(int requestID, INPUT requestMessage, Promise promise)
    • Method Detail

      • send

        void send​(int requestID,
                  INPUT requestMessage,
                  Promise promise)
        This needs to contain the logic for sending a message with an id over the asynchronous I/O channel.

        NOTE: So far, the use of the classes Promise, Script and Sender has solely been for the Browser Remote Debug Protocol. For that use, the instance of Sender used is the 'send' method will simply transmit a Json java.lang.String to over a WebSocket.

        ALSO: See that the 'promise' that is ultimately returned to the user needs to be passed as a parameter here.
        requestID - The ID of the request-message. This ID allows the asynchronous logic to match responses to requests, since they are received asynchronously.
        requestMessage - The message to be sent. For the Browser RPD System, this message will always be a JSON java.lang.String.
        promise - The promise that's going to be returned to the user.

        NOTE: It may be obvious that the instance of Promise here is a Raw-Type instance of a generic class. The reason that the Promise is instantiated inside the Script.exec() method is precisely because the generic types are not used here.

        Because the class Script creates the Promise, and immediately returns it to the user, the generic-type parameters are much easier to ignore. Note that, currently, the only implementing class of Sender is the WebSocketSender. This classes has SuppressWarnings annotations for Raw-Types at the top of the page.