我在项目上使用Stomp Protocol Android,但是在连接服务器时收到成功消息,但需要传递标头以从服务器获取有效负载。我将标头传递到List中,但它不起作用,如何实现呢?以下是我的实现:
map=new HashMap<>();
map.put("token",token);
mStompClient = Stomp.over(WebSocket.class, url,map);
mStompClient.topic(editTopic.getText().toString().trim()).subscribe(new Action1<StompMessage>() {
@Override
public void call(StompMessage stompMessage) {
//Log.e(TAG, "payload"+stompMessage.getPayload());
Log.e(TAG, "headers>" + stompMessage.getStompHeaders());
Log.e(TAG, "command>>>" + stompMessage.getStompCommand());
}
mStompClient.lifecycle().subscribe(new Action1<LifecycleEvent>() {
@Override
public void call(LifecycleEvent lifecycleEvent) {
switch (lifecycleEvent.getType()) {
case OPENED:
Log.e(TAG, "Stomp connection opened");
break;
case ERROR:
Log.e(TAG, "Error", lifecycleEvent.getException());
break;
case CLOSED:
Log.e(TAG, "Stomp connection closed");
break;
}
}
});
mStompClient.connect();
}
});