Class ClientCommunicator
java.lang.Object
ch.autumo.beetroot.server.communication.Communicator
ch.autumo.beetroot.server.communication.ClientCommunicator
Client communicator.
-
Field Summary
Fields inherited from class Communicator
CMD_FILE_DELETE, CMD_FILE_RECEIVE_REQUEST, CMD_FILE_REQUEST, CMD_HEALTH, CMD_STOP, HTTP_HEADER_ACCEPT_JSON, HTTP_HEADER_CONTENTTYPE_JSON_UTF8, LOG, MAX_MSG_SIZE, TIMEOUT, USER_AGENTModifier and TypeFieldDescriptionstatic final StringFile deletestatic final StringFile receive request for uploadstatic final StringFile request for downloadstatic final StringHealth commandstatic final StringStop commandstatic final String[]HTTP Header accept with 'application/json'.static final String[]HTTP Header accept with 'application/json; charset=utf-8'.protected static final org.slf4j.LoggerLogger for this class.static final intMax.static final intConnection timeout in secondsstatic final StringUser agents used for tunneled server commands. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ClientAnswerRead an answer from the server client side.static voidreInit()Re-initialize client communicator.static ClientAnswersendServerCommand(ServerCommand command) Send a server command client side.Methods inherited from class Communicator
checkHttpResponse, isInternalCommand, read, readCommand, readJsonCommand, safeClose, writeAnswerModifier and TypeMethodDescriptionstatic voidcheckHttpResponse(org.apache.http.client.methods.CloseableHttpResponse resp) Check closeable HTTP response with HttpResponse.protected static booleanisInternalCommand(ServerCommand command) Is it an internal command?protected static Stringread(DataInputStream in) Server- or client-side read.static ServerCommandRead a server command server side.static ServerCommandreadJsonCommand(InputStream in, int length) Read a JSON server command server side.static final voidSafe close for closeable object (e.g.static voidwriteAnswer(ClientAnswer answer, DataOutputStream out) Write/send client answer from server to client.
-
Constructor Details
-
ClientCommunicator
public ClientCommunicator()Default constructor.
-
-
Method Details
-
reInit
public static void reInit()Re-initialize client communicator. -
sendServerCommand
Send a server command client side.- Parameters:
command- server command- Returns:
- client answer
- Throws:
Exception- exception
-
readAnswer
Read an answer from the server client side.- Parameters:
in- input stream- Returns:
- client answer or null, if answer received was invalid
- Throws:
IOException- IO exception
-