use of org.roof.im.gateway.ConnectNotExistException 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