use of com.github.jnidzwetzki.bitfinex.v2.callback.command.ConnectionHeartbeatCallback in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class CommandsCallbackTest method testConnectionHeartbeat.
/**
* Test the pong callback
* @throws APIException
*/
@Test
public void testConnectionHeartbeat() throws APIException {
final String jsonString = "{\"event\":\"pong\",\"ts\":1515023251265}";
final JSONObject jsonObject = new JSONObject(jsonString);
final BitfinexApiBroker bitfinexApiBroker = new BitfinexApiBroker();
final long oldHeartbeat = bitfinexApiBroker.getLastHeatbeat().get();
final ConnectionHeartbeatCallback connectionHeartbeatCallback = new ConnectionHeartbeatCallback();
connectionHeartbeatCallback.handleChannelData(bitfinexApiBroker, jsonObject);
final long newHeartbeat = bitfinexApiBroker.getLastHeatbeat().get();
Assert.assertTrue(oldHeartbeat < newHeartbeat);
}
use of com.github.jnidzwetzki.bitfinex.v2.callback.command.ConnectionHeartbeatCallback in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class BitfinexApiBroker method setupCommandCallbacks.
/**
* Setup the command callbacks
*/
private void setupCommandCallbacks() {
commandCallbacks = new HashMap<>();
commandCallbacks.put("info", new DoNothingCommandCallback());
commandCallbacks.put("subscribed", new SubscribedCallback());
commandCallbacks.put("pong", new ConnectionHeartbeatCallback());
commandCallbacks.put("unsubscribed", new UnsubscribedCallback());
commandCallbacks.put("auth", new AuthCallbackHandler());
}
Aggregations