Making both the GetBlockHeader and GetKeyReferences extend the BaseGrapheneHandler class

This commit is contained in:
Nelson R. Perez 2017-04-13 11:15:48 -05:00
parent fb82ce660e
commit 9b15a0b5da
2 changed files with 19 additions and 41 deletions

View file

@ -3,12 +3,7 @@ package de.bitsharesmunich.graphenej.api;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
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 de.bitsharesmunich.graphenej.RPC;
import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
import de.bitsharesmunich.graphenej.models.*;
import java.io.Serializable;
import java.lang.reflect.Type;
@ -16,10 +11,18 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
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.BlockHeader;
import de.bitsharesmunich.graphenej.models.WitnessResponse;
/**
* Created by nelson on 12/13/16.
*/
public class GetBlockHeader extends WebSocketAdapter {
public class GetBlockHeader extends BaseGrapheneHandler {
// Sequence of message ids
private final static int LOGIN_ID = 1;
private final static int GET_DATABASE_ID = 2;
@ -32,6 +35,7 @@ public class GetBlockHeader extends WebSocketAdapter {
private int apiId = -1;
public GetBlockHeader(long blockNumber, WitnessResponseListener listener){
super(listener);
this.blockNumber = blockNumber;
this.mListener = listener;
}
@ -87,16 +91,4 @@ public class GetBlockHeader extends WebSocketAdapter {
if(frame.isTextFrame())
System.out.println(">>> "+frame.getPayloadText());
}
@Override
public void onError(WebSocket websocket, WebSocketException cause) throws Exception {
System.out.println("onError. Msg: "+cause.getMessage());
websocket.disconnect();
}
@Override
public void handleCallbackError(WebSocket websocket, Throwable cause) throws Exception {
System.out.println("handleCallbackError. Msg: "+cause.getMessage());
websocket.disconnect();
}
}

View file

@ -2,16 +2,7 @@ package de.bitsharesmunich.graphenej.api;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import de.bitsharesmunich.graphenej.Address;
import de.bitsharesmunich.graphenej.RPC;
import de.bitsharesmunich.graphenej.UserAccount;
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 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;
@ -20,15 +11,22 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import de.bitsharesmunich.graphenej.Address;
import de.bitsharesmunich.graphenej.RPC;
import de.bitsharesmunich.graphenej.UserAccount;
import de.bitsharesmunich.graphenej.interfaces.WitnessResponseListener;
import de.bitsharesmunich.graphenej.models.ApiCall;
import de.bitsharesmunich.graphenej.models.WitnessResponse;
/**
* Created by nelson on 11/15/16.
*/
public class GetAccountsByAddress extends BaseGrapheneHandler {
public class GetKeyReferences extends BaseGrapheneHandler {
private Address address;
private WitnessResponseListener mListener;
public GetAccountsByAddress(Address address, WitnessResponseListener listener) {
public GetKeyReferences(Address address, WitnessResponseListener listener) {
super(listener);
this.address = address;
this.mListener = listener;
@ -66,16 +64,4 @@ public class GetAccountsByAddress extends BaseGrapheneHandler {
if(frame.isTextFrame())
System.out.println(">>> "+frame.getPayloadText());
}
@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();
}
}