Skip to content

Instantly share code, notes, and snippets.

@sirolf2009
Created January 23, 2018 08:26
Show Gist options
  • Save sirolf2009/ba72381dd581900bd97d3782a6f0bbd1 to your computer and use it in GitHub Desktop.
Save sirolf2009/ba72381dd581900bd97d3782a6f0bbd1 to your computer and use it in GitHub Desktop.
@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