1.5K Star 12.1K Fork 3.3K

GVP轨迹 / J-IM

 / 详情

当用TCP连接进行握手操作的时候,报错不执行onAfterHandshake

待办的
创建于  
2020-05-06 17:26

当用TCP连接进行握手操作的时候,org.jim.server.command.handler.HandshakeReqHandler第36行因为wsSessionContext=null报错,导致不会执行后面的onAfterHandshake

评论 (2)

舒服吗 创建了任务
舒服吗 关联仓库设置为轨迹/J-IM
展开全部操作日志
package org.jim.server.command.handler;

import java.util.Objects;
import org.jim.core.ImChannelContext;
import org.jim.core.ImPacket;
import org.jim.core.exception.ImException;
import org.jim.core.http.HttpRequest;
import org.jim.core.packets.Command;
import org.jim.core.ws.WsSessionContext;
import org.jim.server.JimServerAPI;
import org.jim.server.command.AbstractCmdHandler;
import org.jim.server.processor.handshake.HandshakeCmdProcessor;

public class HandshakeReqHandler extends AbstractCmdHandler {
    public HandshakeReqHandler() {
    }

    public ImPacket handler(ImPacket packet, ImChannelContext channelContext) throws ImException {
        HandshakeCmdProcessor handshakeProcessor = (HandshakeCmdProcessor)this.getMultiProcessor(channelContext, HandshakeCmdProcessor.class);
        if (Objects.isNull(handshakeProcessor)) {
            JimServerAPI.remove(channelContext, "没有对应的握手协议处理器HandshakeCmdProcessor...");
            return null;
        } else {
            ImPacket handShakePacket = handshakeProcessor.handshake(packet, channelContext);
            if (handShakePacket == null) {
                JimServerAPI.remove(channelContext, "业务层不同意握手");
                return null;
            } else {
                JimServerAPI.send(channelContext, handShakePacket);
                WsSessionContext wsSessionContext = (WsSessionContext)channelContext.getSessionContext();
                HttpRequest request = wsSessionContext.getHandshakeRequestPacket();
                handshakeProcessor.onAfterHandshake(request, channelContext);
                return null;
            }
        }
    }

    public Command command() {
        return Command.COMMAND_HANDSHAKE_REQ;
    }
}

HttpRequest request = wsSessionContext.getHandshakeRequestPacket();

轨迹 任务状态待办的 修改为已完成
轨迹 任务状态已完成 修改为待办的

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(2)
410355 xchao 1578923025
Java
1
https://gitee.com/xchao/j-im.git
git@gitee.com:xchao/j-im.git
xchao
j-im
J-IM

搜索帮助