0

I want to use the polonex api via the wamp protocol and the jawampa library. My first try is to subscribe for ticker events, here is the documentation for this event:

In order to receive ticker updates, subscribe to "ticker". Updates will be in the following format: ['BTC_BBR','0.00069501','0.00074346','0.00069501','-0.00742634','8.63286802','11983.47150109',0,'0.00107920','0.00045422'] Appropriate labels for these data are, in order: currencyPair, last, lowestAsk, highestBid, percentChange, baseVolume, quoteVolume, isFrozen, 24hrHigh, 24hrLow

I use this piece of code for the subscription:

        clientp.statusChanged().subscribe(new Action1<WampClient.State>() {
        @Override
        public void call(WampClient.State t1) {
            System.out.println("Sessione R ora è " + t1);

            if (t1 instanceof WampClient.ConnectedState) {
                System.out.println("Client P ricevuto " + t1);
                    eventSubscription = clientp.makeSubscription("ticker", String.class)
                    .subscribe(new Action1<String>() {

        @Override
        public void call(String t1) {
        System.out.println("ES ricevuto " + eventSubscription);
        System.out.println("Client P ricevuto " + t1);

I only receive the first field of the update (currencyPair) how too read the full update?

Thank you in advance for any help.:)

TitusI
  • 31
  • 5

1 Answers1

0

The messages you receive are not of type String, but instead are of type PubSubData. Try this (Java pseudocode; I'm using Scala):

if (t1 instanceof WampClient.ConnectedState) {
                System.out.println("Client P ricevuto " + t1);
                    eventSubscription = clientp.makeSubscription("ticker")
                    .subscribe(new Action1<PubSubData>() {

        @Override
        public void call(PubSubData message) {
        System.out.println("Received " + message.arguments().toString());
arosca
  • 469
  • 7
  • 15
  • Thank you @arosca now I receive the full update using a client from gitub from user xkrajnan https://github.com/xkrajnan/PoloniexClient/ I'm learning. :) – TitusI Apr 19 '17 at 15:13