|
|
@@ -1,6 +1,7 @@
|
|
|
package com.nb.common.websocket.filter;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.nb.common.websocket.msg.MessagingRequest;
|
|
|
import com.nb.common.websocket.PubResponse;
|
|
|
@@ -21,7 +22,7 @@ import org.tio.websocket.common.WsResponse;
|
|
|
public class DefaultPubMsgFilter implements PubMsgFilter {
|
|
|
@Override
|
|
|
public boolean doFilter(ChannelContext channelContext, MessagingRequest source) {
|
|
|
- if(source.getKey()!=null){
|
|
|
+ if(StrUtil.isBlank(source.getKey())){
|
|
|
Tio.send(channelContext, WsResponse.fromText(JSONUtil.toJsonStr(PubResponse.fail("","发布消息时key不能为空")), WsPacket.CHARSET_NAME));
|
|
|
return false;
|
|
|
}
|