mirror of
https://gitee.com/xchao/j-im.git
synced 2024-12-03 12:27:35 +08:00
调整消息响应cmd命令结构体
This commit is contained in:
parent
e008cac449
commit
b68cd8d425
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user