如何使用Jawampa(Java WAMP实现)在活动中订阅



我想通过wamp协议和jawampa库使用polonex api。我的第一次尝试是订阅ticker事件,以下是此事件的文档:

若要接收ticker更新,请订阅"ticker"。更新将采用以下格式:['BTC_BBR','0.00069501','0.00743464','0.0069501','-0.00742634','8.63286802','1983.47150109',0,'0.00107920','0.000045422']这些数据的适当标签依次为:currencyAir,last,最低要价,最高出价,百分比变化,基本成交量,报价成交量,is冻结,24小时高,24小时低

我使用这段代码进行订阅:

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

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

提前感谢您的帮助。:)

您收到的消息不是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());

相关内容

  • 没有找到相关文章

最新更新