private ReactorNettyTcpClient<byte[]> initTcpClient() { StompDecoder decoder = new StompDecoder(); if (this.headerInitializer != null) { decoder.setHeaderInitializer(this.headerInitializer); } ReactorNettyCodec<byte[]> codec = new StompReactorNettyCodec(decoder); ReactorNettyTcpClient<byte[]> client = new ReactorNettyTcpClient<>(this.relayHost, this.relayPort, codec); client.setLogger(SimpLogging.forLog(client.getLogger())); return client; }
/** * Decodes one or more STOMP frames from the given {@code ByteBuffer} into a * list of {@link Message Messages}. If the input buffer contains partial STOMP frame * content, or additional content with a partial STOMP frame, the buffer is * reset and {@code null} is returned. * @param byteBuffer the buffer to decode the STOMP frame from * @return the decoded messages, or an empty list if none * @throws StompConversionException raised in case of decoding issues */ public List<Message<byte[]>> decode(ByteBuffer byteBuffer) { return decode(byteBuffer, null); }
Message<byte[]> message = decodeMessage(byteBuffer, partialMessageHeaders); if (message != null) { messages.add(message);
private Message<byte[]> decodeMessage(ByteBuffer byteBuffer, @Nullable MultiValueMap<String, String> headers) { Message<byte[]> decodedMessage = null; skipLeadingEol(byteBuffer); buffer.mark(); String command = readCommand(byteBuffer); if (command.length() > 0) { StompHeaderAccessor headerAccessor = null; StompCommand stompCommand = StompCommand.valueOf(command); headerAccessor = StompHeaderAccessor.create(stompCommand); initHeaders(headerAccessor); readHeaders(byteBuffer, headerAccessor); payload = readPayload(byteBuffer, headerAccessor); initHeaders(headerAccessor); headerAccessor.setLeaveMutable(true); decodedMessage = MessageBuilder.createMessage(HEARTBEAT_PAYLOAD, headerAccessor.getMessageHeaders());
public StompReactorNettyCodec() { this(new StompDecoder()); }
/** * Configure a {@link MessageHeaderInitializer} to apply to the headers of all * messages created from decoded STOMP frames and other messages sent to the * client inbound channel. * <p>By default this property is not set. */ public void setHeaderInitializer(@Nullable MessageHeaderInitializer headerInitializer) { this.headerInitializer = headerInitializer; this.stompDecoder.setHeaderInitializer(headerInitializer); }
private void initHeaders(StompHeaderAccessor headerAccessor) { MessageHeaderInitializer initializer = getHeaderInitializer(); if (initializer != null) { initializer.initHeaders(headerAccessor); } }
private Message<byte[]> decodeMessage(ByteBuffer byteBuffer, @Nullable MultiValueMap<String, String> headers) { Message<byte[]> decodedMessage = null; skipLeadingEol(byteBuffer); buffer.mark(); String command = readCommand(byteBuffer); if (command.length() > 0) { StompHeaderAccessor headerAccessor = null; StompCommand stompCommand = StompCommand.valueOf(command); headerAccessor = StompHeaderAccessor.create(stompCommand); initHeaders(headerAccessor); readHeaders(byteBuffer, headerAccessor); payload = readPayload(byteBuffer, headerAccessor); initHeaders(headerAccessor); headerAccessor.setLeaveMutable(true); decodedMessage = MessageBuilder.createMessage(HEARTBEAT_PAYLOAD, headerAccessor.getMessageHeaders());
public StompReactorNettyCodec() { this(new StompDecoder()); }
/** * Configure a {@link MessageHeaderInitializer} to apply to the headers of all * messages created from decoded STOMP frames and other messages sent to the * client inbound channel. * <p>By default this property is not set. */ public void setHeaderInitializer(@Nullable MessageHeaderInitializer headerInitializer) { this.headerInitializer = headerInitializer; this.stompDecoder.setHeaderInitializer(headerInitializer); }
private void initHeaders(StompHeaderAccessor headerAccessor) { MessageHeaderInitializer initializer = getHeaderInitializer(); if (initializer != null) { initializer.initHeaders(headerAccessor); } }
private Message<byte[]> decodeMessage(ByteBuffer byteBuffer, @Nullable MultiValueMap<String, String> headers) { Message<byte[]> decodedMessage = null; skipLeadingEol(byteBuffer); buffer.mark(); String command = readCommand(byteBuffer); if (command.length() > 0) { StompHeaderAccessor headerAccessor = null; StompCommand stompCommand = StompCommand.valueOf(command); headerAccessor = StompHeaderAccessor.create(stompCommand); initHeaders(headerAccessor); readHeaders(byteBuffer, headerAccessor); payload = readPayload(byteBuffer, headerAccessor); initHeaders(headerAccessor); headerAccessor.setLeaveMutable(true); decodedMessage = MessageBuilder.createMessage(HEARTBEAT_PAYLOAD, headerAccessor.getMessageHeaders());
private ReactorNettyTcpClient<byte[]> initTcpClient() { StompDecoder decoder = new StompDecoder(); if (this.headerInitializer != null) { decoder.setHeaderInitializer(this.headerInitializer); } ReactorNettyCodec<byte[]> codec = new StompReactorNettyCodec(decoder); ReactorNettyTcpClient<byte[]> client = new ReactorNettyTcpClient<>(this.relayHost, this.relayPort, codec); client.setLogger(SimpLogging.forLog(client.getLogger())); return client; }
@Override protected List<Message<byte[]>> decodeInternal(ByteBuffer nioBuffer) { return this.decoder.decode(nioBuffer); }
public StompReactorNettyCodec() { this(new StompDecoder()); }
/** * Configure a {@link MessageHeaderInitializer} to apply to the headers of all * messages created from decoded STOMP frames and other messages sent to the * client inbound channel. * <p>By default this property is not set. */ public void setHeaderInitializer(@Nullable MessageHeaderInitializer headerInitializer) { this.headerInitializer = headerInitializer; this.stompDecoder.setHeaderInitializer(headerInitializer); }
private void initHeaders(StompHeaderAccessor headerAccessor) { MessageHeaderInitializer initializer = getHeaderInitializer(); if (initializer != null) { initializer.initHeaders(headerAccessor); } }
Message<byte[]> message = decodeMessage(byteBuffer, partialMessageHeaders); if (message != null) { messages.add(message);
private Message<byte[]> decodeMessage(ByteBuffer byteBuffer, @Nullable MultiValueMap<String, String> headers) { Message<byte[]> decodedMessage = null; skipLeadingEol(byteBuffer); buffer.mark(); String command = readCommand(byteBuffer); if (command.length() > 0) { StompHeaderAccessor headerAccessor = null; StompCommand stompCommand = StompCommand.valueOf(command); headerAccessor = StompHeaderAccessor.create(stompCommand); initHeaders(headerAccessor); readHeaders(byteBuffer, headerAccessor); payload = readPayload(byteBuffer, headerAccessor); initHeaders(headerAccessor); headerAccessor.setLeaveMutable(true); decodedMessage = MessageBuilder.createMessage(HEARTBEAT_PAYLOAD, headerAccessor.getMessageHeaders());
private ReactorNettyTcpClient<byte[]> initTcpClient() { StompDecoder decoder = new StompDecoder(); if (this.headerInitializer != null) { decoder.setHeaderInitializer(this.headerInitializer); } ReactorNettyCodec<byte[]> codec = new StompReactorNettyCodec(decoder); ReactorNettyTcpClient<byte[]> client = new ReactorNettyTcpClient<>(this.relayHost, this.relayPort, codec); client.setLogger(SimpLogging.forLog(client.getLogger())); return client; }