|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object context.arch.comm.protocol.TCPClientSocket context.arch.comm.protocol.HTTPClientSocket
This class subclasses TCPClientSocket, creating and sending HTTP requests. It implements the CommunicationsClient interface
TCPClientSocket
,
CommunicationsClient
Field Summary | |
static boolean |
DEBUG
Debug flag. |
static int |
DEFAULT_PORT
Default port to use is 5555 |
static java.lang.String |
GET
HTTP GET request type |
static java.lang.String |
POST
HTTP POST request type |
static java.lang.String |
PROTOCOL
The protocol being used is HTTP |
Fields inherited from class context.arch.comm.protocol.TCPClientSocket |
DEFAULT_SERVER, portNumber, remoteServer |
Constructor Summary | |
HTTPClientSocket(CommunicationsObject object)
Basic constructor for HTTPClientSocket that calls TCPClientSocket |
|
HTTPClientSocket(CommunicationsObject object,
java.lang.String server,
java.lang.Integer port)
Constructor for HTTPClientSocket that calls TCPClientSocket with the given port |
Method Summary | |
java.lang.String |
addRequestProtocol(java.lang.String data,
java.lang.String url)
This method adds the HTTP protocol for a POST request (POST is the default) |
java.lang.String |
addRequestProtocol(java.lang.String data,
java.lang.String url,
java.lang.String type)
Method that adds the HTTP protocol to a request message |
DataObject |
getErrorMessage()
This method generates an error message if a request can't be handled properly, to the point where a contextual error message can still be sent as the reply. |
java.lang.String |
getFatalMessage()
This method generates an fatal message if a request can't be handled properly, to the point where no contextual error message can be sent as the reply. |
java.lang.String |
getProtocol()
Method to get the communications protocol being used |
java.net.Socket |
sendRequest(java.lang.String content)
This method sends a request to a remote server |
RequestData |
stripReplyProtocol(java.net.Socket data)
Method that strips away the HTTP protocol from a reply message |
java.lang.String |
toString()
|
Methods inherited from class context.arch.comm.protocol.TCPClientSocket |
getPort, getServer, setPort, setServer |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static boolean DEBUG
public static final java.lang.String PROTOCOL
public static final java.lang.String GET
public static final java.lang.String POST
public static final int DEFAULT_PORT
Constructor Detail |
public HTTPClientSocket(CommunicationsObject object)
object
- Handle of the generic instantiating communications objectDEFAULT_PORT
,
TCPClientSocket
public HTTPClientSocket(CommunicationsObject object, java.lang.String server, java.lang.Integer port)
object
- Handle of the generic instantiating communications objectserver
- Hostname of the remote server to connect toport
- Port to use to receive communications onTCPServerSocket
Method Detail |
public java.lang.String addRequestProtocol(java.lang.String data, java.lang.String url) throws ProtocolException
addRequestProtocol
in interface CommunicationsClient
data
- The request to add the protocol tourl
- The recipient of the request (eg, an URL in HTTP). May be null.
ProtocolException
- thrown if protocol can't be addedCommunicationsClient.stripReplyProtocol(Socket)
,
CommunicationsServer.stripRequestProtocol(Socket)
,
CommunicationsServer.addReplyProtocol(String)
public java.lang.String addRequestProtocol(java.lang.String data, java.lang.String url, java.lang.String type) throws ProtocolException
addRequestProtocol
in interface CommunicationsClient
data
- Request message to add HTTP protocol tourl
- Tag/URL to add to messagetype
- The type of the request: GET or POST.
ProtocolException
- if the protocol
can not be addedCommunicationsClient.stripReplyProtocol(Socket)
,
CommunicationsServer.stripRequestProtocol(Socket)
,
CommunicationsServer.addReplyProtocol(String)
public RequestData stripReplyProtocol(java.net.Socket data) throws ProtocolException
stripReplyProtocol
in interface CommunicationsClient
data
- The socket the reply is being received on
ProtocolException
- if the protocol
can not be stripped awayCommunicationsClient.addRequestProtocol(String,String)
,
CommunicationsServer.stripRequestProtocol(Socket)
,
CommunicationsServer.addReplyProtocol(String)
public DataObject getErrorMessage()
getErrorMessage
in interface CommunicationsClient
getFatalMessage()
public java.lang.String getFatalMessage()
getFatalMessage
in interface CommunicationsClient
getErrorMessage()
public java.net.Socket sendRequest(java.lang.String content) throws java.io.IOException
sendRequest
in interface CommunicationsClient
content
- The request to send
java.io.IOException
public java.lang.String getProtocol()
getProtocol
in interface CommunicationsClient
PROTOCOL
public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |