更新时间:2021-11-17 20:41:14
尝试创建类似Bean的
try to create a Bean like
public class SimpleBean{
private String from;
private String text;
public String getFrom(){return from;}
public String getText(){return text:}
//other methods like setters here...
}
然后以这种方式设置messageConverter
then set the messageConverter in this way
MappingJackson2MessageConverter m = new MappingJackson2MessageConverter();
stompClient.setMessageConverter(m);
在"afterConnected(StompSession会话,StompHeaders connectedHeaders)"方法中,我的客户端没有调用"subscribe"方法
I have not seen any invocation of the "subscribe" method for your client in the method "afterConnected(StompSession session, StompHeaders connectedHeaders)"
session.subscribe(subscribeMethod, new StompFrameHandler() {
//.. overriding for public Type getPayloadType(StompHeaders headers) {} and
// public void handleFrame(StompHeaders headers, Object payload) {} here
});
使用前面定义的SimpleBean实例,而不是调用"send"方法:
Than call for the "send" method, using an instance for the SimpleBean defined just before:
SimpleBean sb=new SimpleBean();
sb.setFrom("cliente1");
sb.setText("KIKO");
session.send("/app/chatchannel", sb);
这应该有帮助.