u
This commit is contained in:
1 parent
db2208cc92
commit
35951777b0
13 files changed
+225
-151
No files matched your search
@@ -1,12 +1,10 @@
|
||||
package com.link.im.handler;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.link.im.manager.GroupManager;
|
||||
import com.link.im.manager.UserChannelManager;
|
||||
import com.link.im.manager.WriteManager;
|
||||
import com.link.im.model.ChatMessage;
|
||||
import io.netty.channel.Channel;
|
||||
import com.link.im.model.ImMessage;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
@@ -15,9 +13,6 @@ import io.netty.handler.timeout.IdleStateEvent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ChannelHandler.Sharable
|
||||
public class ImWebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ImWebSocketHandler.class);
|
||||
@@ -43,9 +38,9 @@ public class ImWebSocketHandler extends SimpleChannelInboundHandler<TextWebSocke
|
||||
protected void channelRead0(ChannelHandlerContext ctx, TextWebSocketFrame msg) throws Exception {
|
||||
String text = msg.text();
|
||||
try {
|
||||
ChatMessage chatMsg = MAPPER.readValue(text, ChatMessage.class);
|
||||
ImMessage imMessage = MAPPER.readValue(text, ImMessage.class);
|
||||
|
||||
System.out.println(chatMsg);
|
||||
System.out.println(imMessage);
|
||||
} catch (Exception e) {
|
||||
WriteManager.writeToChannel(ctx.channel(),"JSON格式错误");
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.link.im.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ChatMessage {
|
||||
private String type;
|
||||
private String msg;
|
||||
|
||||
public ChatMessage() {
|
||||
}
|
||||
|
||||
public ChatMessage(String type, String msg) {
|
||||
this.type = type;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChatMessage{" +
|
||||
"type='" + type + '\'' +
|
||||
", msg='" + msg + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.link.im.model;
|
||||
|
||||
public class ImMessage {
|
||||
private String type;
|
||||
private String msg;
|
||||
private String from;
|
||||
private String to;
|
||||
private String content;
|
||||
private long timestamp;
|
||||
|
||||
public ImMessage() {
|
||||
}
|
||||
|
||||
public ImMessage(String type, String content, String msg, String from, String to, long timestamp) {
|
||||
this.type = type;
|
||||
this.content = content;
|
||||
this.msg = msg;
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public String getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public void setTo(String to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user