We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 14bd566 commit 0784c33Copy full SHA for 0784c33
docs/system-design/web-real-time-message-push.md
@@ -374,6 +374,22 @@ public class WebSocketServer {
374
}
375
```
376
377
+服务端还需要注入`ServerEndpointerExporter`,这个 Bean 就会自动注册使用了`@ServerEndpoint`注解的 WebSocket 服务器。
378
+
379
+```java
380
+@Configuration
381
+public class WebSocketConfiguration {
382
383
+ /**
384
+ * 用于注册使用了 @ServerEndpoint 注解的 WebSocket 服务器
385
+ */
386
+ @Bean
387
+ public ServerEndpointExporter serverEndpointExporter() {
388
+ return new ServerEndpointExporter();
389
+ }
390
+}
391
+```
392
393
前端初始化打开 WebSocket 连接,并监听连接状态,接收服务端数据或向服务端发送数据。
394
395
```javascript
0 commit comments