Java Code Examples for org.springframework.web.socket.sockjs.frame.SockJsFrame#getContent()
The following examples show how to use
org.springframework.web.socket.sockjs.frame.SockJsFrame#getContent() .
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: RestTemplateXhrTransportTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void connectReceiveAndCloseWithStompFrame() throws Exception { StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.SEND); accessor.setDestination("/destination"); MessageHeaders headers = accessor.getMessageHeaders(); Message<byte[]> message = MessageBuilder.createMessage("body".getBytes(StandardCharsets.UTF_8), headers); byte[] bytes = new StompEncoder().encode(message); TextMessage textMessage = new TextMessage(bytes); SockJsFrame frame = SockJsFrame.messageFrame(new Jackson2SockJsMessageCodec(), textMessage.getPayload()); String body = "o\n" + frame.getContent() + "\n" + "c[3000,\"Go away!\"]"; ClientHttpResponse response = response(HttpStatus.OK, body); connect(response); verify(this.webSocketHandler).afterConnectionEstablished(any()); verify(this.webSocketHandler).handleMessage(any(), eq(textMessage)); verify(this.webSocketHandler).afterConnectionClosed(any(), eq(new CloseStatus(3000, "Go away!"))); verifyNoMoreInteractions(this.webSocketHandler); }
Example 2
Source File: RestTemplateXhrTransportTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void connectReceiveAndCloseWithStompFrame() throws Exception { StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.SEND); accessor.setDestination("/destination"); MessageHeaders headers = accessor.getMessageHeaders(); Message<byte[]> message = MessageBuilder.createMessage("body".getBytes(StandardCharsets.UTF_8), headers); byte[] bytes = new StompEncoder().encode(message); TextMessage textMessage = new TextMessage(bytes); SockJsFrame frame = SockJsFrame.messageFrame(new Jackson2SockJsMessageCodec(), textMessage.getPayload()); String body = "o\n" + frame.getContent() + "\n" + "c[3000,\"Go away!\"]"; ClientHttpResponse response = response(HttpStatus.OK, body); connect(response); verify(this.webSocketHandler).afterConnectionEstablished(any()); verify(this.webSocketHandler).handleMessage(any(), eq(textMessage)); verify(this.webSocketHandler).afterConnectionClosed(any(), eq(new CloseStatus(3000, "Go away!"))); verifyNoMoreInteractions(this.webSocketHandler); }
Example 3
Source File: RestTemplateXhrTransportTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void connectReceiveAndCloseWithStompFrame() throws Exception { StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.SEND); accessor.setDestination("/destination"); MessageHeaders headers = accessor.getMessageHeaders(); Message<byte[]> message = MessageBuilder.createMessage("body".getBytes(Charset.forName("UTF-8")), headers); byte[] bytes = new StompEncoder().encode(message); TextMessage textMessage = new TextMessage(bytes); SockJsFrame frame = SockJsFrame.messageFrame(new Jackson2SockJsMessageCodec(), textMessage.getPayload()); String body = "o\n" + frame.getContent() + "\n" + "c[3000,\"Go away!\"]"; ClientHttpResponse response = response(HttpStatus.OK, body); connect(response); verify(this.webSocketHandler).afterConnectionEstablished(any()); verify(this.webSocketHandler).handleMessage(any(), eq(textMessage)); verify(this.webSocketHandler).afterConnectionClosed(any(), eq(new CloseStatus(3000, "Go away!"))); verifyNoMoreInteractions(this.webSocketHandler); }
Example 4
Source File: WebSocketServerSockJsSession.java From spring-analysis-note with MIT License | 5 votes |
@Override protected void writeFrameInternal(SockJsFrame frame) throws IOException { Assert.state(this.webSocketSession != null, "WebSocketSession not yet initialized"); if (logger.isTraceEnabled()) { logger.trace("Writing " + frame); } TextMessage message = new TextMessage(frame.getContent()); this.webSocketSession.sendMessage(message); }
Example 5
Source File: WebSocketServerSockJsSession.java From java-technology-stack with MIT License | 5 votes |
@Override protected void writeFrameInternal(SockJsFrame frame) throws IOException { Assert.state(this.webSocketSession != null, "WebSocketSession not yet initialized"); if (logger.isTraceEnabled()) { logger.trace("Writing " + frame); } TextMessage message = new TextMessage(frame.getContent()); this.webSocketSession.sendMessage(message); }
Example 6
Source File: WebSocketServerSockJsSession.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override protected void writeFrameInternal(SockJsFrame frame) throws IOException { if (logger.isTraceEnabled()) { logger.trace("Writing " + frame); } TextMessage message = new TextMessage(frame.getContent()); this.webSocketSession.sendMessage(message); }