use of org.springframework.web.socket.TextMessage in project spring-boot-starter-samples by vindell.
the class WebsocketEndPoint method handleTextMessage.
@Override
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
super.handleTextMessage(session, message);
TextMessage returnMessage = new TextMessage(message.getPayload() + " received at server");
session.sendMessage(returnMessage);
}
use of org.springframework.web.socket.TextMessage in project roof-im by madfroglx.
the class WebSocketResponseEndPoint method send.
@Override
public void send(String connectId, Response response) throws IOException, ConnectNotExistException {
WebSocketSession webSocketSession = webSocketSessionConnectManager.get(connectId);
if (webSocketSession == null) {
throw new ConnectNotExistException();
}
// if (!webSocketSession.isOpen()) {
// return;
// }
TextMessage textMessage = new TextMessage(JSON.toJSONString(response));
try {
webSocketSession.sendMessage(textMessage);
} catch (Exception e) {
// 消息推送异常则关闭连接
WebSocketUtils.tryCloseWithError(webSocketSession, e, LOGGER);
throw e;
}
}
Aggregations