import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
+import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
return host + ":" + port;
}
+ @Override
+ public Status getStatus() {
+ final Status[] result = new Status[1];
+
+ result[0] = Status.INVALID;
+
+ ConnectActionClientObject action = null;
+ try {
+ action = new ConnectActionClientObject(host, port, true) {
+ @Override
+ public void action(Version serverVersion) throws Exception {
+ Object rep = send(new Object[] { key, "PING" });
+ if ("PONG".equals(rep)) {
+ result[0] = Status.READY;
+ } else {
+ result[0] = Status.UNAUTORIZED;
+ }
+ }
+
+ @Override
+ protected void onError(Exception e) {
+ result[0] = Status.UNAVAILABLE;
+ }
+ };
+
+ } catch (UnknownHostException e) {
+ result[0] = Status.INVALID;
+ } catch (IllegalArgumentException e) {
+ result[0] = Status.INVALID;
+ } catch (Exception e) {
+ result[0] = Status.UNAVAILABLE;
+ }
+
+ if (action != null) {
+ try {
+ action.connect();
+ } catch (Exception e) {
+ result[0] = Status.UNAVAILABLE;
+ }
+ }
+
+ return result[0];
+ }
+
@Override
public BufferedImage getCover(final String luid) {
final BufferedImage[] result = new BufferedImage[1];