Java Code Examples for org.springframework.core.io.buffer.NettyDataBufferFactory#toByteBuf()

The following examples show how to use org.springframework.core.io.buffer.NettyDataBufferFactory#toByteBuf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NettyWebSocketSessionSupport.java    From spring-analysis-note with MIT License 6 votes vote down vote up
protected WebSocketFrame toFrame(WebSocketMessage message) {
	ByteBuf byteBuf = NettyDataBufferFactory.toByteBuf(message.getPayload());
	if (WebSocketMessage.Type.TEXT.equals(message.getType())) {
		return new TextWebSocketFrame(byteBuf);
	}
	else if (WebSocketMessage.Type.BINARY.equals(message.getType())) {
		return new BinaryWebSocketFrame(byteBuf);
	}
	else if (WebSocketMessage.Type.PING.equals(message.getType())) {
		return new PingWebSocketFrame(byteBuf);
	}
	else if (WebSocketMessage.Type.PONG.equals(message.getType())) {
		return new PongWebSocketFrame(byteBuf);
	}
	else {
		throw new IllegalArgumentException("Unexpected message type: " + message.getType());
	}
}
 
Example 2
Source File: NettyWebSocketSessionSupport.java    From java-technology-stack with MIT License 6 votes vote down vote up
protected WebSocketFrame toFrame(WebSocketMessage message) {
	ByteBuf byteBuf = NettyDataBufferFactory.toByteBuf(message.getPayload());
	if (WebSocketMessage.Type.TEXT.equals(message.getType())) {
		return new TextWebSocketFrame(byteBuf);
	}
	else if (WebSocketMessage.Type.BINARY.equals(message.getType())) {
		return new BinaryWebSocketFrame(byteBuf);
	}
	else if (WebSocketMessage.Type.PING.equals(message.getType())) {
		return new PingWebSocketFrame(byteBuf);
	}
	else if (WebSocketMessage.Type.PONG.equals(message.getType())) {
		return new PongWebSocketFrame(byteBuf);
	}
	else {
		throw new IllegalArgumentException("Unexpected message type: " + message.getType());
	}
}
 
Example 3
Source File: BufferConverter.java    From vertx-spring-boot with Apache License 2.0 4 votes vote down vote up
public Buffer toBuffer(DataBuffer dataBuffer) {
    ByteBuf byteBuf = NettyDataBufferFactory.toByteBuf(dataBuffer);
    return Buffer.buffer(byteBuf);
}