Skip to content
This repository has been archived by the owner on Jun 8, 2020. It is now read-only.

Gdax disconnect and reconnect fixes, binance isAlive implementation #126

Merged
merged 1 commit into from
Mar 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Completable disconnect() {

@Override
public boolean isAlive() {
throw new IllegalStateException("Not implemented.");
return streamingService!= null && streamingService.isSocketOpen();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,33 @@
public class GDAXStreamingExchange extends GDAXExchange implements StreamingExchange {
private static final String API_URI = "wss://ws-feed.gdax.com";

private final GDAXStreamingService streamingService;
private GDAXStreamingService streamingService;
private GDAXStreamingMarketDataService streamingMarketDataService;

public GDAXStreamingExchange() {
this.streamingService = new GDAXStreamingService(API_URI);
}
public GDAXStreamingExchange() { }

@Override
protected void initServices() {
super.initServices();
streamingMarketDataService = new GDAXStreamingMarketDataService(streamingService);
}

@Override
public Completable connect(ProductSubscription... args) {
if (args == null || args.length == 0)
throw new UnsupportedOperationException("The ProductSubscription must be defined!");
this.streamingService = new GDAXStreamingService(API_URI);
this.streamingMarketDataService = new GDAXStreamingMarketDataService(this.streamingService);
streamingService.subscribeMultipleCurrencyPairs(args);

return streamingService.connect();
}

@Override
public Completable disconnect() {
return streamingService.disconnect();
GDAXStreamingService service = this.streamingService;
streamingService = null;
streamingMarketDataService = null;
return service.disconnect();
}

@Override
Expand All @@ -65,6 +67,6 @@ public void setChannelInactiveHandler(WebSocketClientHandler.WebSocketMessageHan

@Override
public boolean isAlive() {
return streamingService.isSocketOpen();
return streamingService != null && streamingService.isSocketOpen();
}
}