NaikSoftware / StompProtocolAndroid

STOMP protocol via WebSocket for Android
MIT License
597 stars 265 forks source link

Can't send multiple STOMP messages #31

Open dimonik opened 7 years ago

dimonik commented 7 years ago

If I do this

mStompClient = Stomp.over(WebSocket.class, endpoint);
mStompClient.connect();

and immediately following with

switch (lifecycleEvent.getType())
{
    case OPENED:
        mStompClient.send(stomp_p2p_channel, msg_body);

then message is sent successfully.

If i do sending one more time (after 5 sec)

mStompClient.send(stomp_p2p_channel, msg_body);

the message is NOT sent, despite connection is still alive.

Bug?

KyleADOlson commented 7 years ago

Try mStompClient.send(stomp_p2p_channel, msg_body).subscribe();

dimonik commented 7 years ago

Thank you, this work!

But, could you explain why client need to subscribe for each sent message?

forresthopkinsa commented 7 years ago

send returns an Observable, which means it shouldn't do anything unless subscribed to. If you don't know what an Observable is, read this.