0

我想通过 wamp 协议和 jawampa 库使用 polonex api。我的第一次尝试是订阅股票事件,这里是这个事件的文档:

为了接收股票更新,订阅“股票”。更新将采用以下格式:['BTC_BBR','0.00069501','0.00074346','0.00069501','-0.00742634','8.63286802','11983.47150109',0,'0.00107920','0.00045422'标签这些数据依次为:currencyPair、last、lowestAsk、highestBid、percentChange、baseVolume、quoteVolume、isFrozen、24hrHigh、24hrLow

我将这段代码用于订阅:

        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);

我只收到更新的第一个字段(currencyPair)怎么读完整的更新?

预先感谢您的任何帮助。:)

4

1 回答 1

0

您收到的消息不是 String 类型,而是 PubSubData 类型。试试这个(Java 伪代码;我使用的是 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());
于 2016-08-17T18:35:12.253 回答