Skip to content

Commit 92077a5

Browse files
authored
[Optimization-4314][admin] Optimize WebSocket for asynchronous sending (#4315)
1 parent d621bc8 commit 92077a5

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

dinky-admin/src/main/java/org/dinky/ws/GlobalWebSocket.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void onMessage(String message, Session session) throws IOException {
109109

110110
if (requestDTO.getType() == RequestDTO.EventType.PING) {
111111
WsDataVo data = new WsDataVo(session.getId(), RequestDTO.EventType.PONG);
112-
session.getBasicRemote().sendText(JsonUtils.toJsonString(data));
112+
session.getAsyncRemote().sendText(JsonUtils.toJsonString(data));
113113
return;
114114
}
115115

@@ -153,12 +153,7 @@ private void firstSend() {
153153
}
154154

155155
private void send(Session session, WsDataVo data) {
156-
try {
157-
session.getBasicRemote().sendText(JsonUtils.toJsonString(data));
158-
} catch (IOException e) {
159-
log.error("send ws data error", e);
160-
throw new RuntimeException(e);
161-
}
156+
session.getAsyncRemote().sendText(JsonUtils.toJsonString(data));
162157
}
163158

164159
public void sendTopic(GlobalWebSocketTopic topic, Set<String> params, Map<String, Object> result) {

0 commit comments

Comments
 (0)