implement connect to Elite Dangerous Companion
This commit is contained in:
45
utils/src/test/java/ru/trader/edce/EDSessionDemo.java
Normal file
45
utils/src/test/java/ru/trader/edce/EDSessionDemo.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package ru.trader.edce;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class EDSessionDemo {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(EDSessionDemo.class);
|
||||
|
||||
private static String readLine(String format, Object... args) throws IOException {
|
||||
if (System.console() != null) {
|
||||
return System.console().readLine(format, args);
|
||||
}
|
||||
System.out.print(String.format(format, args));
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||
System.in));
|
||||
return reader.readLine();
|
||||
}
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
LOG.info("Test ED Companion connect");
|
||||
EDSession edSession = new EDSession("frontier@mail.ru","elite");
|
||||
if (edSession.getLastStatus() == ED_SESSION_STATUS.OK){
|
||||
LOG.info("Check get profile");
|
||||
edSession.readProfile(s ->{});
|
||||
}
|
||||
if (edSession.getLastStatus() == ED_SESSION_STATUS.LOGIN_REQUIRED) {
|
||||
edSession.login();
|
||||
if (edSession.getLastStatus() == ED_SESSION_STATUS.VERIFICATION_REQUIRED) {
|
||||
LOG.info("Check verification");
|
||||
String code = readLine("Verify code:");
|
||||
edSession.submitVerifyCode(code);
|
||||
edSession.login();
|
||||
}
|
||||
if (edSession.getLastStatus() == ED_SESSION_STATUS.OK) {
|
||||
LOG.info("Check get profile");
|
||||
edSession.readProfile(s -> {});
|
||||
}
|
||||
}
|
||||
edSession.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user