public class HTTPFramer extends Object
The base HTTPFramer treats the content of each HTTP POST (to the /xmit/ URL) as a simple string being delivered to the server.
Constructor and Description |
---|
HTTPFramer(Trace msgTrace)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
String |
makeBadURLReply(String badURL)
Produce the HTTP reply body for responding to an unrecognized URL (that
is, a 404 error).
|
String |
makeConnectReply(long sessionID)
Produce the HTTP reply body containing the JSON string for responding to
an HTTP GET or POST of the /connect/ URL.
|
String |
makeDisconnectReply()
Produce the HTTP reply body containing the JSON string for responding to
an HTTP GET or POST of the /disconnect/ URL.
|
String |
makeSelectReplySegment(Object message,
int seqNumber,
boolean start,
boolean end)
Produce a fragment of the HTTP reply body containing JSON messages in
response to an HTTP GET or POST of the /select/ URL.
|
String |
makeSequenceErrorReply(String error)
Produce the HTTP reply body containing the JSON string for responding to
an HTTP GET or POST where the URL that was presented to the server had
an out-of-sequence sequence number or a bad session ID number.
|
String |
makeXmitReply(int seqNumber)
Produce the HTTP reply body containing the JSON string for responding to
an HTTP GET or POST of the /xmit/ URL used to transmit messages from the
client to the server.
|
Iterator |
postBodyUnpacker(String postBody)
Return an iterator that will return the application-level message or
messages (if any) in the body of a received HTTP POST.
|
public HTTPFramer(Trace msgTrace)
msgTrace
- Trace object for logging message traffic.public String makeBadURLReply(String badURL)
badURL
- The URL that was no good.public String makeConnectReply(long sessionID)
sessionID
- The session ID number for the session.public String makeDisconnectReply()
public String makeSelectReplySegment(Object message, int seqNumber, boolean start, boolean end)
This method is able to produce fragmentary output to support packing multiple messages into a single reply body: the reply consists of a prefix, the actual encoding of the message(s) being sent, and then a suffix. The prefix is only produced if the 'start' parameter is true; likewise for the suffix and the 'end' parameter. It is possible to concatenate the fragments generated by any number of calls to this method to produce a valid reply body, so long as the 'start' parameter is set on the first call (and not the others), and the 'end' parameter is set on the last call (and not the others).
message
- The message to be sent, or null if no messages are to be
sent.seqNumber
- The sequence number for the next select request.start
- true if this message is the first in a batch.end
- true if this message is the last in a batch.public String makeSequenceErrorReply(String error)
error
- Error string to transmit.public String makeXmitReply(int seqNumber)
seqNumber
- The sequence number for the next xmit request.public Iterator postBodyUnpacker(String postBody)
postBody
- The HTTP POST body in question.Copyright © 2017. All rights reserved.