info.bitrich.xchangestream.serum.SerumStreamingExchange Maven / Gradle / Ivy
The newest version!
package info.bitrich.xchangestream.serum;
import com.knowm.xchange.serum.SerumConfigs.Solana;
import com.knowm.xchange.serum.SerumExchange;
import info.bitrich.xchangestream.core.ProductSubscription;
import info.bitrich.xchangestream.core.StreamingExchange;
import info.bitrich.xchangestream.core.StreamingMarketDataService;
import info.bitrich.xchangestream.service.netty.ConnectionStateModel;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Observable;
import org.knowm.xchange.ExchangeSpecification;
public class SerumStreamingExchange extends SerumExchange implements StreamingExchange {
private SerumStreamingService streamingService;
@Override
public Completable connect(ProductSubscription... args) {
final String url =
Solana.valueOf(
String.valueOf(getExchangeSpecification().getExchangeSpecificParametersItem("Env")))
.wsUrl();
this.streamingService = new SerumStreamingService(url);
applyStreamingSpecification(getExchangeSpecification(), this.streamingService);
return this.streamingService.connect();
}
@Override
public Completable disconnect() {
final SerumStreamingService service = streamingService;
streamingService = null;
return service.disconnect();
}
@Override
public Observable reconnectFailure() {
return streamingService.subscribeReconnectFailure();
}
@Override
public Observable