public class ByondClient extends Object
create()
method.
ByondMessage messageToSend = new ByondMessage(new ServerAddress("bagil.game.tgstation13.org", 2337), "?ping");
ByondClient client = new ByondClient();
ByondResponse response = client.sendMessage(messageToSend);
Sending process could be made in one line style:
ByondResponse response = ByondClient.create().sendMessage(messageToSend);
Message sending is based on Socket
class and process of reading returned data is built on
reacting on SocketTimeoutException
, due to BYOND doesn't send 'end byte'.
Constructor and Description |
---|
ByondClient() |
Modifier and Type | Method and Description |
---|---|
static ByondClient |
create()
Static method create
ByondClient instance
without constructor. |
void |
sendCommand(ByondMessage byondMessage)
Send message to BYOND server without waiting for response.
|
ByondResponse |
sendMessage(ByondMessage byondMessage)
Send message to BYOND server with waiting for response.
|
ByondResponse |
sendMessage(ByondMessage byondMessage,
int readTimeout)
Send message to BYOND server with waiting for response.
|
public static ByondClient create()
ByondClient
instance
without constructor.ByondClient
instance.public void sendCommand(ByondMessage byondMessage) throws HostUnavailableException
byondMessage
- message to send.HostUnavailableException
- signals that requested server unavailable to connect. Offline or some other reason.public ByondResponse sendMessage(ByondMessage byondMessage) throws HostUnavailableException, UnexpectedResponseTypeException, EmptyResponseException, UnknownResponseException
sendMessage(ByondMessage, int)
but without second argument,
so as reading timeout 500 ms used.byondMessage
- mesasge to send.ByondResponse
or as null, if message response type was ResponseType.NONE
.HostUnavailableException
- signals that requested server unavailable to connect. Offline or some other reason.UnexpectedResponseTypeException
- thrown if expected response doesn't equals to actual.EmptyResponseException
- thrown if response was empty, but user wait for something. Cause could be in
BYOND server itself. Typical, it doesn't handle message which was send and, as a result, not provide any response.UnknownResponseException
public ByondResponse sendMessage(ByondMessage byondMessage, int readTimeout) throws HostUnavailableException, UnexpectedResponseTypeException, EmptyResponseException, UnknownResponseException
byondMessage
- message to send.readTimeout
- timeout time to read response.ByondResponse
or as null, if message response type was ResponseType.NONE
.HostUnavailableException
- signals that requested server unavailable to connect. Offline or some other reason.UnexpectedResponseTypeException
- thrown if expected response doesn't equals to actual.EmptyResponseException
- thrown if response was empty, but user wait for something. Cause could be in
BYOND server itself. Typical, it doesn't handle message which was send and, as a result, not provide any response.UnknownResponseException
Copyright © 2017. All rights reserved.