Created
January 23, 2018 08:26
-
-
Save sirolf2009/ba72381dd581900bd97d3782a6f0bbd1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@FinalFieldsConstructor static class BitfinexActor extends AbstractActor { | |
extension val ActorHelper helper = new ActorHelper(this) | |
val bitfinex = new AtomicReference<BitfinexWebsocketClient>() | |
val String symbol | |
override preStart() throws Exception { | |
connect() | |
} | |
override createReceive() { | |
throw new UnsupportedOperationException("TODO: auto-generated method stub") | |
} | |
@Subscribe def void onSubscribed(OnSubscribed onSubscribed) { | |
info("Subscribed to " + onSubscribed.response) | |
} | |
@Subscribe def void onDisconnected(OnDisconnected onDisconnected) { | |
error("Disconnected from bitfinex. Reconecting...") | |
connect() | |
} | |
def void connect() { | |
info("Connecting to bitfinex") | |
bitfinex.set(new BitfinexWebsocketClient()) | |
bitfinex.get() => [ | |
eventBus.register(this) | |
connectBlocking() | |
send(new SubscribeTrades(symbol)) | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment