public class ByondMessage extends Object
Container for message, which will be sent to BYOND server.
Has server address as ServerAddress
(used by ByondClient
to know, where message should be send),
message as String
and type of expected response as ResponseType
.
Message must contain question mark in the beginning of string, but it could be omitted,
because it will be added on send process automatically if missing. So "ping" and "?ping" will do the same.
Also, message itself is like a parameters for HTTP request, so multiple messages in one send is possible.
To do it all params should be divided with ";" or "&".
For example: "ping&data=123&status
".
Expected response type checked on response validation process. If real response doesn't match,
exception UnexpectedResponseTypeException
will be thrown.
Default expected response is ResponseType.ANY
.
Constructor and Description |
---|
ByondMessage() |
ByondMessage(ServerAddress serverAddress,
String message) |
ByondMessage(ServerAddress serverAddress,
String message,
ResponseType expectedResponse) |
ByondMessage(String serverName,
int serverPort,
String message) |
ByondMessage(String serverName,
int serverPort,
String message,
ResponseType expectedResponse) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
ResponseType |
getExpectedResponse() |
String |
getMessage() |
String |
getMessageAsTopic()
Checks if message has question mark in the beginning, and, if it isn't,
adds it and return new string, so message in 'this' instance doesn't touched.
|
ServerAddress |
getServerAddress() |
int |
hashCode() |
void |
setExpectedResponse(ResponseType expectedResponse) |
void |
setMessage(String message) |
void |
setServerAddress(ServerAddress serverAddress) |
String |
toString() |
public ByondMessage()
public ByondMessage(ServerAddress serverAddress, String message)
public ByondMessage(ServerAddress serverAddress, String message, ResponseType expectedResponse)
public ByondMessage(String serverName, int serverPort, String message, ResponseType expectedResponse)
public String getMessageAsTopic()
public ServerAddress getServerAddress()
public void setServerAddress(ServerAddress serverAddress)
public String getMessage()
public void setMessage(String message)
public ResponseType getExpectedResponse()
public void setExpectedResponse(ResponseType expectedResponse)
Copyright © 2017. All rights reserved.