Get account name WS

This commit is contained in:
Henry Varona 2016-11-26 18:45:36 -04:00
parent 8a5c7e51a4
commit f8d07ccc64
3 changed files with 3 additions and 8 deletions

View file

@ -64,7 +64,6 @@ public class Address {
factory.setSSLContext(context); factory.setSSLContext(context);
WebSocket mWebSocket = factory.createSocket(OPENLEDGER_WITNESS_URL); WebSocket mWebSocket = factory.createSocket(OPENLEDGER_WITNESS_URL);
mWebSocket.addListener(new GetAccountsByAddress(this.toString(), accountIdListener)); mWebSocket.addListener(new GetAccountsByAddress(this.toString(), accountIdListener));
System.out.println("Before connecting");
mWebSocket.connect(); mWebSocket.connect();
} catch (IOException e) { } catch (IOException e) {
System.out.println("IOException. Msg: " + e.getMessage()); System.out.println("IOException. Msg: " + e.getMessage());
@ -95,11 +94,9 @@ public class Address {
if (sl.size() > 0) { if (sl.size() > 0) {
accountId = (String) sl.get(0); accountId = (String) sl.get(0);
try { try {
// Create a custom SSL context.
SSLContext context = NaiveSSLContext.getInstance("TLS"); SSLContext context = NaiveSSLContext.getInstance("TLS");
WebSocketFactory factory = new WebSocketFactory(); WebSocketFactory factory = new WebSocketFactory();
factory.setSSLContext(context); factory.setSSLContext(context);
WebSocket mWebSocket = factory.createSocket(OPENLEDGER_WITNESS_URL); WebSocket mWebSocket = factory.createSocket(OPENLEDGER_WITNESS_URL);
mWebSocket.addListener(new GetAccountNameById(accountId, accountListener)); mWebSocket.addListener(new GetAccountNameById(accountId, accountListener));
mWebSocket.connect(); mWebSocket.connect();
@ -139,7 +136,6 @@ public class Address {
if (response.result.getClass() == ArrayList.class) { if (response.result.getClass() == ArrayList.class) {
List l = (List) response.result; List l = (List) response.result;
if (l.size() > 0) { if (l.size() > 0) {
System.out.println("list class " + l.get(0).getClass());
if (l.get(0).getClass() == LinkedTreeMap.class) { if (l.get(0).getClass() == LinkedTreeMap.class) {
LinkedTreeMap ltm = (LinkedTreeMap) l.get(0); LinkedTreeMap ltm = (LinkedTreeMap) l.get(0);
accountName = (String) ltm.get("name"); accountName = (String) ltm.get("name");

View file

@ -607,7 +607,8 @@ public class Test {
public void testAccountNamebyAddress() { public void testAccountNamebyAddress() {
BrainKey brainKey = new BrainKey(Main.BRAIN_KEY, 0); BrainKey brainKey = new BrainKey(Main.BRAIN_KEY, 0);
Address address = new Address(brainKey.getPrivateKey()); Address address = new Address(brainKey.getPrivateKey());
address.getAccountName(); address.getAccountDetail();
System.out.println(address.getAccountName());
/*try { /*try {
BrainKey brainKey = new BrainKey(Main.BRAIN_KEY, 0); BrainKey brainKey = new BrainKey(Main.BRAIN_KEY, 0);
Address address = new Address(brainKey.getPrivateKey()); Address address = new Address(brainKey.getPrivateKey());

View file

@ -77,7 +77,6 @@ public class ApiCall implements JsonSerializable {
methodParams.add((String) this.params.get(i)); methodParams.add((String) this.params.get(i));
}else if(this.params.get(i) instanceof ArrayList){ }else if(this.params.get(i) instanceof ArrayList){
// Other times it might be an array // Other times it might be an array
System.out.println("es un arreglo");
JsonArray array = new JsonArray(); JsonArray array = new JsonArray();
ArrayList<JsonSerializable> listArgument = (ArrayList<JsonSerializable>) this.params.get(i); ArrayList<JsonSerializable> listArgument = (ArrayList<JsonSerializable>) this.params.get(i);
for(int l = 0; l < listArgument.size(); l++){ for(int l = 0; l < listArgument.size(); l++){
@ -90,7 +89,6 @@ public class ApiCall implements JsonSerializable {
paramsArray.add(methodParams); paramsArray.add(methodParams);
obj.add(KEY_PARAMS, paramsArray); obj.add(KEY_PARAMS, paramsArray);
obj.addProperty(KEY_JSON_RPC, this.jsonrpc); obj.addProperty(KEY_JSON_RPC, this.jsonrpc);
System.out.println("JSON Object: " + obj.toString());
return obj; return obj;
} }