mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 12:39:05 +08:00
✨ Introducing new features. closed #3301 common-websocket 提供默认的文本处理器
This commit is contained in:
1 parent
964aff613c
commit
8e2cd1234a
3 files changed
+33
-1
No files matched your search
+7
@@ -2,6 +2,7 @@ package com.pig4cloud.pigx.common.websocket.config;
|
||||
|
||||
import com.pig4cloud.pigx.common.websocket.custom.PigxSessionKeyGenerator;
|
||||
import com.pig4cloud.pigx.common.websocket.custom.UserAttributeHandshakeInterceptor;
|
||||
import com.pig4cloud.pigx.common.websocket.handler.CustomPlanTextMessageHandler;
|
||||
import com.pig4cloud.pigx.common.websocket.handler.CustomWebSocketHandler;
|
||||
import com.pig4cloud.pigx.common.websocket.handler.PingJsonMessageHandler;
|
||||
import com.pig4cloud.pigx.common.websocket.handler.PlanTextMessageHandler;
|
||||
@@ -40,6 +41,12 @@ public class WebSocketHandlerConfig {
|
||||
return new UserAttributeHandshakeInterceptor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(PlanTextMessageHandler.class)
|
||||
public PlanTextMessageHandler planTextMessageHandler() {
|
||||
return new CustomPlanTextMessageHandler();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean({ TextWebSocketHandler.class, PlanTextMessageHandler.class })
|
||||
public WebSocketHandler webSocketHandler1(@Autowired(required = false) SessionKeyGenerator sessionKeyGenerator) {
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.pig4cloud.pigx.common.websocket.handler;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2021/11/4
|
||||
*
|
||||
* 默认消息处理
|
||||
*/
|
||||
@Slf4j
|
||||
public class CustomPlanTextMessageHandler implements PlanTextMessageHandler {
|
||||
|
||||
/**
|
||||
* 普通文本消息处理
|
||||
* @param session 当前接收消息的session
|
||||
* @param message 文本消息
|
||||
*/
|
||||
@Override
|
||||
public void handle(WebSocketSession session, String message) {
|
||||
log.info("sessionId {} ,msg {}", session.getId(), message);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ import org.springframework.web.socket.WebSocketSession;
|
||||
/**
|
||||
* 普通文本类型(非指定json类型)的消息处理器 即消息不满足于我们定义的Json类型消息时,所使用的处理器
|
||||
*
|
||||
* @see JsonWebSocketMessage
|
||||
* @see com.pig4cloud.pigx.common.websocket.message.JsonWebSocketMessage
|
||||
* @author Hccake 2021/1/5
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user