Subscribe with callback, onNext method not working
Hello, I'm trying to use StompClient without retrolambda Why with the following code I can get the message from the server (with retrolambda)?:
mStompClient.topic("/topic/hello").subscribe(topicMessage -> {
Log.d("listenStomp", topicMessage.getPayload());
});
But when I subscribe to the same topic, with the following code, I never get the message from the "onNext ()" method
mStompClient.topic("/topic/hello").subscribe(new Subscriber<StompMessage>() {
@Override
public void onSubscribe(Subscription s) {
Log.d("listenStomp", "onSubscribe");
}
@Override
public void onNext(StompMessage stompMessage) {
Log.d("listenStomp", "onNext");
Log.d(TAG, "Received " + stompMessage.getPayload());
}
@Override
public void onError(Throwable t) {
Log.d("listenStomp", "onError", t);
}
@Override
public void onComplete() {
Log.d("listenStomp", "onComplete");
}
});
Also, what would the "Action1" class look like in this example ?:
mStompClient.topic("/topic/greetings").subscribe(new Action1<StompMessage>() {
@Override
public void call(StompMessage stompMessage) {
Log.d("hoangdinhhung", stompMessage.getPayload());
}
});
Your second code block there works for me. And I don't get your question about Action1; it applies to onNext.
Also, this library relies on Retrolambda. If you don't want to use Retrolambda or Jack, and you're using Native Java 8 compilation, try using the fork. Let me know your results.
Somebody help me mStompClient.send() is not sending messages to server but mStompClient.topic() receives message