类org.springframework.messaging.simp.stomp.StompDecoder源码实例Demo

下面列出了怎么用org.springframework.messaging.simp.stomp.StompDecoder的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: WeEvent   文件: WebSocketTransport.java

@Override
public void onMessage(String message) {
    log.debug("received message");

    //decode from message
    StompDecoder decoder = new StompDecoder();
    List<Message<byte[]>> messages = decoder.decode(ByteBuffer.wrap(message.getBytes(StandardCharsets.UTF_8)));
    for (Message<byte[]> stompMsg : messages) {
        // handle the frame from the server
        handleFrame(stompMsg);
    }
}
 
源代码2 项目: WeEvent   文件: BrokerStomp.java

@Override
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
    if (!sessionContext.containsKey(session.getId())) {
        log.error("unknown session id, skip it");
        return;
    }

    List<Message<byte[]>> stompMsg = new StompDecoder().decode(ByteBuffer.wrap(message.getPayload().getBytes(StandardCharsets.UTF_8)));
    for (Message<byte[]> msg : stompMsg) {
        this.handleSingleMessage(msg, session);
    }
}
 

/**
 * Configure a {@link StompDecoder} for decoding STOMP frames.
 * @since 4.3.5
 */
public void setDecoder(StompDecoder decoder) {
	this.stompDecoder = decoder;
}
 

/**
 * Configure a {@link StompDecoder} for decoding STOMP frames.
 * @since 4.3.5
 */
public void setDecoder(StompDecoder decoder) {
	this.stompDecoder = decoder;
}
 
 类方法
 同包方法