diff --git a/tio-im-server/src/main/java/org/tio/im/server/command/handler/ChatReqHandler.java b/tio-im-server/src/main/java/org/tio/im/server/command/handler/ChatReqHandler.java index 509aef0..f6a6b87 100644 --- a/tio-im-server/src/main/java/org/tio/im/server/command/handler/ChatReqHandler.java +++ b/tio-im-server/src/main/java/org/tio/im/server/command/handler/ChatReqHandler.java @@ -63,7 +63,7 @@ public class ChatReqHandler extends CmdHandler { respPacket.setStatus(ImStatus.C0); return respPacket; }else{ - RespBody chatRespBody = new RespBody().setCode(ImStatus.C1.getCode()).setCommand(Command.COMMAND_CHAT_RESP).setMsg(JSONObject.toJSONString(chatBody)); + RespBody chatRespBody = new RespBody().setCommand(Command.COMMAND_CHAT_RESP).setMsg(JSONObject.toJSONString(chatBody)); ImPacket respPacket = Resps.convertPacket(chatRespBody, toChannelContext); respPacket.setStatus(ImStatus.C1); return respPacket; diff --git a/tio-im-server/src/main/java/org/tio/im/server/ws/WsMsgHandler.java b/tio-im-server/src/main/java/org/tio/im/server/ws/WsMsgHandler.java index 56548fb..2bb3307 100644 --- a/tio-im-server/src/main/java/org/tio/im/server/ws/WsMsgHandler.java +++ b/tio-im-server/src/main/java/org/tio/im/server/ws/WsMsgHandler.java @@ -6,12 +6,14 @@ import org.slf4j.LoggerFactory; import org.tio.core.Aio; import org.tio.core.ChannelContext; import org.tio.im.common.ImPacket; +import org.tio.im.common.ImStatus; import org.tio.im.common.http.HttpConst; import org.tio.im.common.http.HttpRequest; import org.tio.im.common.http.HttpResponse; import org.tio.im.common.packets.ChatBody; import org.tio.im.common.packets.Command; import org.tio.im.common.packets.LoginReqBody; +import org.tio.im.common.packets.RespBody; import org.tio.im.common.ws.Opcode; import org.tio.im.common.ws.WsRequestPacket; import org.tio.im.common.ws.WsResponsePacket; @@ -76,8 +78,11 @@ public class WsMsgHandler implements IWsMsgHandler{ ChannelContext toChannleContext = ChatReqHandler.getToChannel(chatBody, channelContext.getGroupContext()); if(toChannleContext != null){ Aio.send(toChannleContext, respChatPacket); + RespBody chatStatusPacket = new RespBody(Command.COMMAND_CHAT_RESP).setCode(ImStatus.C1.getCode()).setMsg(ImStatus.C1.getText()); + text = JSONObject.toJSONString(chatStatusPacket); + }else{ + text = new String(respChatPacket.getBody(),HttpConst.CHARSET_NAME); } - text = new String(respChatPacket.getBody(),HttpConst.CHARSET_NAME); return text; } diff --git a/tio-im-server/src/main/resources/page/index.html b/tio-im-server/src/main/resources/page/index.html index e09d7b4..fae1391 100644 --- a/tio-im-server/src/main/resources/page/index.html +++ b/tio-im-server/src/main/resources/page/index.html @@ -43,7 +43,7 @@ function connect(){ socket.onmessage = function(e){ var data = e.data; var dataObj = eval("("+data+")");//转换为json对象 - if(dataObj.code == 0 && dataObj.command == "COMMAND_CHAT_RESP"){ + if("undefined" == typeof(dataObj.code) && dataObj.command == "COMMAND_CHAT_RESP"){ var chatObj = eval("("+dataObj.msg+")"); var createTime = new Date(chatObj.createTime).Format("yyyy/MM/dd HH:mm:ss"); var from = chatObj.from;