use of org.springframework.web.socket.TextMessage in project spring-boot by spring-projects.
the class SimpleClientWebSocketHandler method afterConnectionEstablished.
@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
TextMessage message = new TextMessage(this.greetingService.getGreeting());
session.sendMessage(message);
}
use of org.springframework.web.socket.TextMessage in project spring-boot by spring-projects.
the class SimpleClientWebSocketHandler method afterConnectionEstablished.
@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
TextMessage message = new TextMessage(this.greetingService.getGreeting());
session.sendMessage(message);
}
use of org.springframework.web.socket.TextMessage in project spring-framework by spring-projects.
the class AbstractSockJsSession method delegateMessages.
public void delegateMessages(String... messages) throws SockJsMessageDeliveryException {
List<String> undelivered = new ArrayList<>(Arrays.asList(messages));
for (String message : messages) {
try {
if (isClosed()) {
throw new SockJsMessageDeliveryException(this.id, undelivered, "Session closed");
} else {
this.handler.handleMessage(this, new TextMessage(message));
undelivered.remove(0);
}
} catch (Throwable ex) {
throw new SockJsMessageDeliveryException(this.id, undelivered, ex);
}
}
}
use of org.springframework.web.socket.TextMessage in project spring-framework by spring-projects.
the class StompWebSocketIntegrationTests method sendSubscribeToControllerAndReceiveReply.
// SPR-11648
@Test
public void sendSubscribeToControllerAndReceiveReply() throws Exception {
String destHeader = "destination:/app/number";
TextMessage message = create(StompCommand.SUBSCRIBE).headers("id:subs1", destHeader).build();
TestClientWebSocketHandler clientHandler = new TestClientWebSocketHandler(1, message);
WebSocketSession session = doHandshake(clientHandler, "/ws").get();
try {
assertTrue(clientHandler.latch.await(TIMEOUT, TimeUnit.SECONDS));
String payload = clientHandler.actual.get(0).getPayload();
assertTrue("Expected STOMP destination=/app/number, got " + payload, payload.contains(destHeader));
assertTrue("Expected STOMP Payload=42, got " + payload, payload.contains("42"));
} finally {
session.close();
}
}
use of org.springframework.web.socket.TextMessage in project spring-framework by spring-projects.
the class StompWebSocketIntegrationTests method sendMessageToController.
@Test
public void sendMessageToController() throws Exception {
TextMessage message = create(StompCommand.SEND).headers("destination:/app/simple").build();
WebSocketSession session = doHandshake(new TestClientWebSocketHandler(0, message), "/ws").get();
SimpleController controller = this.wac.getBean(SimpleController.class);
try {
assertTrue(controller.latch.await(TIMEOUT, TimeUnit.SECONDS));
} finally {
session.close();
}
}
Aggregations