Package Torello.Java.Additional
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 withWebSockets
, and in that case,'INPUT'
type would be of typejava.lang.String
.
NOTE: The contents of thatString
are in JSON format.
- All Known Implementing Classes:
WebSocketSender
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface 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
andSender
are designed to allow for the creation of 'Asynchronous Scripts' that may be executed and made to appear to be synchronous through thePromise.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.
Hi-Lited Source-Code:- View Here: Torello/Java/Additional/Sender.java
- Open New Browser-Tab: Torello/Java/Additional/Sender.java
File Size: 2,233 Bytes Line Count: 44 '\n' Characters Found
-
-
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 classesPromise
,Script
andSender
has solely been for the Browser Remote Debug Protocol. For that use, the instance ofSender
used is the'send'
method will simply transmit a Jsonjava.lang.String
to over aWebSocket
.
ALSO: See that the'promise'
that is ultimately returned to the user needs to be passed as a parameter here.- Parameters:
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 JSONjava.lang.String
.promise
- The promise that's going to be returned to the user.
NOTE: It may be obvious that the instance ofPromise
here is aRaw-Type
instance of a generic class. The reason that thePromise
is instantiated inside theScript.exec()
method is precisely because the generic types are not used here.
Because the classScript
creates thePromise
, and immediately returns it to the user, the generic-type parameters are much easier to ignore. Note that, currently, the only implementing class ofSender
is theWebSocketSender
.
-
-