StompProtocolAndroid
StompProtocolAndroid copied to clipboard
How to get session id?
How to get session id from client when connect websocket successful?
mStompClient.lifecycle().subscribe(lifecycleEvent -> { switch (lifecycleEvent.getType()) {
case OPENED:
sessionID = // how do I get this?
Log.d(TAG, "Stomp connection opened");
break;
case ERROR:
Log.e(TAG, "Error", lifecycleEvent.getException());
break;
case CLOSED:
Log.d(TAG, "Stomp connection closed");
break;
}
});
What is sessionID
supposed to be?
i want to session id like that https://stackoverflow.com/questions/28009764/how-to-get-session-id-on-the-client-side-websocket
That's SockJS. This library is not SockJS.
Stomp specification 1.2 does specify "session" on connected frame. But this is not "must" implemented feature, but is "may" add it. So if the stomp server you use sets session (which is optional), it will be available on header of connected frame with "session" as key.
Use this library its working fine, replace server url and port with your custom server url and your port. https://github.com/SayyedUmar/Stomp-Android-Client