Search in sources :

Example 1 with CMPPServerChildEndpointEntity

use of com.zx.sms.connect.manager.cmpp.CMPPServerChildEndpointEntity in project SMSGate by Lihuanghe.

the class SessionLoginManager method doLoginSuccess.

@Override
protected void doLoginSuccess(ChannelHandlerContext ctx, EndpointEntity entity, Object msg) {
    CMPPServerChildEndpointEntity childentity = (CMPPServerChildEndpointEntity) entity;
    CmppConnectRequestMessage message = (CmppConnectRequestMessage) msg;
    // channelHandler已绑定完成,给客户端发resp.
    CmppConnectResponseMessage resp = new CmppConnectResponseMessage(message.getHeader().getSequenceId());
    resp.setVersion(childentity.getVersion());
    resp.setStatus(0);
    resp.setAuthenticatorISMG(DigestUtils.md5(Bytes.concat(Ints.toByteArray((int) resp.getStatus()), message.getAuthenticatorSource(), childentity.getPassword().getBytes(childentity.getChartset()))));
    ctx.channel().writeAndFlush(resp);
}
Also used : CMPPServerChildEndpointEntity(com.zx.sms.connect.manager.cmpp.CMPPServerChildEndpointEntity) CmppConnectRequestMessage(com.zx.sms.codec.cmpp.msg.CmppConnectRequestMessage) CmppConnectResponseMessage(com.zx.sms.codec.cmpp.msg.CmppConnectResponseMessage)

Example 2 with CMPPServerChildEndpointEntity

use of com.zx.sms.connect.manager.cmpp.CMPPServerChildEndpointEntity in project SMSGate by Lihuanghe.

the class SessionLoginManager method changeProtoVersion.

@Override
protected void changeProtoVersion(ChannelHandlerContext ctx, EndpointEntity entity, Object msg) throws Exception {
    CmppConnectRequestMessage message = (CmppConnectRequestMessage) msg;
    final short clientVersion = message.getVersion();
    short aim_ver = clientVersion;
    if (entity != null) {
        CMPPServerChildEndpointEntity childentity = (CMPPServerChildEndpointEntity) entity;
        // 以服务端配置的版本为准
        aim_ver = childentity.getVersion();
        // 发送ConnectRequest里的Version跟配置的不同
        if (aim_ver != clientVersion) {
            logger.warn("receive version code {} ,expected version is {} .I would use version {}", clientVersion, aim_ver, aim_ver);
        }
    }
    if ((short) 0x30 != aim_ver) {
        // 以配置的协议版本为准
        // 更换协议解析器
        logger.info("changeCodec to version:{}", aim_ver);
        ctx.pipeline().replace(GlobalConstance.codecName, GlobalConstance.codecName, CMPPCodecChannelInitializer.getCodecHandler(aim_ver));
    }
}
Also used : CMPPServerChildEndpointEntity(com.zx.sms.connect.manager.cmpp.CMPPServerChildEndpointEntity) CmppConnectRequestMessage(com.zx.sms.codec.cmpp.msg.CmppConnectRequestMessage)

Aggregations

CmppConnectRequestMessage (com.zx.sms.codec.cmpp.msg.CmppConnectRequestMessage)2 CMPPServerChildEndpointEntity (com.zx.sms.connect.manager.cmpp.CMPPServerChildEndpointEntity)2 CmppConnectResponseMessage (com.zx.sms.codec.cmpp.msg.CmppConnectResponseMessage)1