001package Torello.Java.Additional;
002
003/**
004 * This functional-interface should have the code/logic for sending an {@code 'INPUT'} message or
005 * request to the asynchronous I/O system/channel.
006 * 
007 * <BR /><BR /><EMBED CLASS='external-html' DATA-FILE-ID=SENDER>
008 * 
009 * @param <INPUT> <EMBED CLASS='external-html' DATA-FILE-ID=INPUT>
010 */
011@FunctionalInterface
012public interface Sender<INPUT>
013{
014    /**
015     * This needs to contain the logic for sending a message with an id over the asynchronous I/O
016     * channel.
017     * 
018     * <BR /><BR /><DIV CLASS=JDHint>
019     * <B STYLE='color: red;'>Note:</B> So far, the use of the classes {@link Promise},
020     * {@link Script} and {@link Sender} has solely been for the Browser Remote Debug Protocol.
021     * For that use, the instance of {@code Sender} used is the {@code 'send'} method will simply
022     * transmit a Json {@code java.lang.String} to over a {@code WebSocket}.
023     * </DIV>
024     * 
025     * <BR /><DIV CLASS=JDHintAlt>
026     * <B STYLE='color: red;'>Furthermore:</B> See that the {@code 'promise'} that is ultimately
027     * returned to the user needs to be passed as a parameter here.
028     * </DIV>
029     * 
030     * @param requestID The ID of the request-message.  This ID allows the asynchronous logic to
031     * match responses to requests, since they are received asynchronously.
032     * 
033     * @param requestMessage The message to be sent.  For the Browser RPD System, this message will
034     * always be a JSON {@code java.lang.String}.
035     * 
036     * @param promise The promise that's going to be returned to the user.
037     * 
038     * <BR /><BR /><DIV CLASS=JDHint>
039     * <B STYLE='color:red;'>Note:</B> It may be obvious that the instance of {@code Promise} here
040     * is a {@code Raw-Type} instance of a generic class.  The reason that the {@code Promise} is 
041     * instantiated inside the {@link Script#exec()} method is precisely because the generic
042     * types are not used here.
043     * </DIV>
044     * 
045     * <BR />Because the class {@code Script} creates the {@code Promise}, and immediately
046     * returns it to the user, the generic-type parameters are much easier to ignore.  Note that,
047     * currently, the only implementing class of {@code Sender} is the {@code WebSocketSender}.
048     */
049    public void send
050        (int requestID, INPUT requestMessage, @SuppressWarnings("rawtypes") Promise promise);
051}