StompProtocolAndroid icon indicating copy to clipboard operation
StompProtocolAndroid copied to clipboard

Subscribe with callback, onNext method not working

Open gustavodbs opened this issue 8 years ago • 2 comments

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

gustavodbs avatar Sep 26 '17 01:09 gustavodbs

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.

forresthopkinsa avatar Sep 26 '17 23:09 forresthopkinsa

Somebody help me mStompClient.send() is not sending messages to server but mStompClient.topic() receives message

Otunbatj avatar Mar 27 '18 17:03 Otunbatj