Fixing merge issues
This commit is contained in:
parent
1532a88736
commit
ca3ae3019b
4 changed files with 38 additions and 128 deletions
|
@ -1,5 +1,4 @@
|
||||||
package com.luminiasoft.bitshares;
|
package de.bitsharesmunich.graphenej;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -15,7 +14,6 @@ public class Market {
|
||||||
public Price sell_price;
|
public Price sell_price;
|
||||||
|
|
||||||
public class Price {
|
public class Price {
|
||||||
|
|
||||||
public AmountPrice base;
|
public AmountPrice base;
|
||||||
public AmountPrice quote;
|
public AmountPrice quote;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,4 +19,5 @@ public class RPC {
|
||||||
public static final String CALL_LOOKUP_ACCOUNTS = "lookup_accounts";
|
public static final String CALL_LOOKUP_ACCOUNTS = "lookup_accounts";
|
||||||
public static final String CALL_LOOKUP_ASSET_SYMBOLS = "lookup_asset_symbols";
|
public static final String CALL_LOOKUP_ASSET_SYMBOLS = "lookup_asset_symbols";
|
||||||
public static final String CALL_GET_BLOCK_HEADER = "get_block_header";
|
public static final String CALL_GET_BLOCK_HEADER = "get_block_header";
|
||||||
|
public static final String CALL_GET_LIMIT_ORDERS = "get_limit_orders";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,87 +0,0 @@
|
||||||
package com.luminiasoft.bitshares.ws;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import com.luminiasoft.bitshares.Asset;
|
|
||||||
import com.luminiasoft.bitshares.RPC;
|
|
||||||
import com.luminiasoft.bitshares.interfaces.JsonSerializable;
|
|
||||||
import com.luminiasoft.bitshares.interfaces.WitnessResponseListener;
|
|
||||||
import com.luminiasoft.bitshares.models.AccountProperties;
|
|
||||||
import com.luminiasoft.bitshares.models.ApiCall;
|
|
||||||
import com.luminiasoft.bitshares.models.BaseResponse;
|
|
||||||
import com.luminiasoft.bitshares.models.WitnessResponse;
|
|
||||||
import com.neovisionaries.ws.client.WebSocket;
|
|
||||||
import com.neovisionaries.ws.client.WebSocketAdapter;
|
|
||||||
import com.neovisionaries.ws.client.WebSocketException;
|
|
||||||
import com.neovisionaries.ws.client.WebSocketFrame;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by nelson on 11/15/16.
|
|
||||||
*/
|
|
||||||
public class GetAsset extends WebSocketAdapter {
|
|
||||||
|
|
||||||
private String assetName;
|
|
||||||
private WitnessResponseListener mListener;
|
|
||||||
|
|
||||||
public GetAsset(String assetName, WitnessResponseListener listener){
|
|
||||||
this.assetName = assetName;
|
|
||||||
this.mListener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onConnected(WebSocket websocket, Map<String, List<String>> headers) throws Exception {
|
|
||||||
ArrayList<Serializable> accountParams = new ArrayList<>();
|
|
||||||
ArrayList<Serializable> assetList = new ArrayList();
|
|
||||||
assetList.add(new JsonSerializable() {
|
|
||||||
@Override
|
|
||||||
public String toJsonString() {
|
|
||||||
return assetName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonElement toJsonObject() {
|
|
||||||
return new JsonParser().parse(assetName);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
accountParams.add(assetList);
|
|
||||||
ApiCall getAccountByName = new ApiCall(0, RPC.CALL_GET_ASSET, accountParams, "2.0", 1);
|
|
||||||
websocket.sendText(getAccountByName.toJsonString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTextFrame(WebSocket websocket, WebSocketFrame frame) throws Exception {
|
|
||||||
String response = frame.getPayloadText();
|
|
||||||
Gson gson = new Gson();
|
|
||||||
|
|
||||||
Type getAssetResponse = new TypeToken<WitnessResponse<ArrayList<Asset>>>(){}.getType();
|
|
||||||
WitnessResponse<ArrayList<Asset>> witnessResponse = gson.fromJson(response, getAssetResponse);
|
|
||||||
|
|
||||||
if(witnessResponse.error != null){
|
|
||||||
this.mListener.onError(witnessResponse.error);
|
|
||||||
}else{
|
|
||||||
this.mListener.onSuccess(witnessResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
websocket.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(WebSocket websocket, WebSocketException cause) throws Exception {
|
|
||||||
mListener.onError(new BaseResponse.Error(cause.getMessage()));
|
|
||||||
websocket.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleCallbackError(WebSocket websocket, Throwable cause) throws Exception {
|
|
||||||
mListener.onError(new BaseResponse.Error(cause.getMessage()));
|
|
||||||
websocket.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +1,17 @@
|
||||||
package com.luminiasoft.bitshares.ws;
|
package de.bitsharesmunich.graphenej.api;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.luminiasoft.bitshares.Market;
|
|
||||||
import com.luminiasoft.bitshares.RPC;
|
|
||||||
import com.luminiasoft.bitshares.interfaces.WitnessResponseListener;
|
|
||||||
import com.luminiasoft.bitshares.models.AccountProperties;
|
|
||||||
import com.luminiasoft.bitshares.models.ApiCall;
|
|
||||||
import com.luminiasoft.bitshares.models.BaseResponse;
|
|
||||||
import com.luminiasoft.bitshares.models.WitnessResponse;
|
|
||||||
import com.neovisionaries.ws.client.WebSocket;
|
import com.neovisionaries.ws.client.WebSocket;
|
||||||
import com.neovisionaries.ws.client.WebSocketAdapter;
|
import com.neovisionaries.ws.client.WebSocketAdapter;
|
||||||
import com.neovisionaries.ws.client.WebSocketException;
|
import com.neovisionaries.ws.client.WebSocketException;
|
||||||
import com.neovisionaries.ws.client.WebSocketFrame;
|
import com.neovisionaries.ws.client.WebSocketFrame;
|
||||||
|
import de.bitsharesmunich.graphenej.Market;
|
||||||
|
import de.bitsharesmunich.graphenej.RPC;
|
||||||
|
import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
|
||||||
|
import de.bitsharesmunich.graphenej.models.ApiCall;
|
||||||
|
import de.bitsharesmunich.graphenej.models.BaseResponse;
|
||||||
|
import de.bitsharesmunich.graphenej.models.WitnessResponse;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
@ -23,14 +22,14 @@ import java.util.Map;
|
||||||
/**
|
/**
|
||||||
* Created by nelson on 11/15/16.
|
* Created by nelson on 11/15/16.
|
||||||
*/
|
*/
|
||||||
public class getLimitOrders extends WebSocketAdapter {
|
public class GetLimitOrders extends WebSocketAdapter {
|
||||||
|
|
||||||
private String a;
|
private String a;
|
||||||
private String b;
|
private String b;
|
||||||
private int limit;
|
private int limit;
|
||||||
private WitnessResponseListener mListener;
|
private WitnessResponseListener mListener;
|
||||||
|
|
||||||
public getLimitOrders(String a, String b, int limit, WitnessResponseListener mListener) {
|
public GetLimitOrders(String a, String b, int limit, WitnessResponseListener mListener) {
|
||||||
this.a = a;
|
this.a = a;
|
||||||
this.b = b;
|
this.b = b;
|
||||||
this.limit = limit;
|
this.limit = limit;
|
||||||
|
@ -43,7 +42,7 @@ public class getLimitOrders extends WebSocketAdapter {
|
||||||
accountParams.add(this.a);
|
accountParams.add(this.a);
|
||||||
accountParams.add(this.b);
|
accountParams.add(this.b);
|
||||||
accountParams.add(this.limit);
|
accountParams.add(this.limit);
|
||||||
ApiCall getAccountByName = new ApiCall(0, RPC.CALL_GET_LIMIT_ORDERS, accountParams, "2.0", 1);
|
ApiCall getAccountByName = new ApiCall(0, RPC.CALL_GET_LIMIT_ORDERS, accountParams, RPC.VERSION, 1);
|
||||||
websocket.sendText(getAccountByName.toJsonString());
|
websocket.sendText(getAccountByName.toJsonString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +52,7 @@ public class getLimitOrders extends WebSocketAdapter {
|
||||||
String response = frame.getPayloadText();
|
String response = frame.getPayloadText();
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
|
|
||||||
Type GetLimitiOrdersResponse = new TypeToken<WitnessResponse<ArrayList<Market>>>() {
|
Type GetLimitiOrdersResponse = new TypeToken<WitnessResponse<ArrayList<Market>>>() {}.getType();
|
||||||
}.getType();
|
|
||||||
WitnessResponse<ArrayList<Market>> witnessResponse = gson.fromJson(response, GetLimitiOrdersResponse);
|
WitnessResponse<ArrayList<Market>> witnessResponse = gson.fromJson(response, GetLimitiOrdersResponse);
|
||||||
if (witnessResponse.error != null) {
|
if (witnessResponse.error != null) {
|
||||||
this.mListener.onError(witnessResponse.error);
|
this.mListener.onError(witnessResponse.error);
|
||||||
|
|
Loading…
Reference in a new issue