use of com.zx.sms.codec.smgp.codec.SMGPMessageCodec in project SMSGate by Lihuanghe.
the class SMGPSessionLoginManager method changeProtoVersion.
@Override
protected void changeProtoVersion(ChannelHandlerContext ctx, EndpointEntity entity, Object msg) throws Exception {
SMGPLoginMessage message = (SMGPLoginMessage) msg;
final short clientVersion = message.getVersion();
short aim_ver = clientVersion;
if (entity != null) {
SMGPServerChildEndpointEntity childentity = (SMGPServerChildEndpointEntity) entity;
// 以服务端配置的版本为准
aim_ver = childentity.getClientVersion();
// 发送ConnectRequest里的Version跟配置的不同
if (aim_ver != clientVersion) {
logger.warn("receive version code {} ,expected version is {} .I would use version {}", clientVersion, aim_ver, aim_ver);
}
}
// 默认的是3.0的协议,如果不是则要更换解析器版本
if ((byte) 0x30 != aim_ver) {
// 以配置的协议版本为准
// 更换协议解析器
logger.info("changeCodec to version:{}", aim_ver);
ctx.pipeline().replace(GlobalConstance.codecName, GlobalConstance.codecName, new SMGPMessageCodec(aim_ver));
}
}
use of com.zx.sms.codec.smgp.codec.SMGPMessageCodec in project SMSGate by Lihuanghe.
the class SMGPCodecChannelInitializer method initChannel.
@Override
protected void initChannel(Channel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addBefore(pipeName(), "FrameDecoder", new LengthFieldBasedFrameDecoder(4 * 1024, 0, 4, -4, 0, true));
pipeline.addBefore(pipeName(), GlobalConstance.codecName, new SMGPMessageCodec(version));
}
Aggregations