Search in sources :

Example 1 with BaseBind

use of com.zx.sms.codec.smpp.msg.BaseBind in project SMSGate by Lihuanghe.

the class SMPPSessionLoginManager method doLogin.

@Override
protected void doLogin(Channel ch) {
    // 发送bind请求
    SMPPEndpointEntity smppentity = (SMPPEndpointEntity) entity;
    BaseBind bind = createBindRequest(smppentity);
    ch.writeAndFlush(bind);
}
Also used : SMPPEndpointEntity(com.zx.sms.connect.manager.smpp.SMPPEndpointEntity) BaseBind(com.zx.sms.codec.smpp.msg.BaseBind)

Example 2 with BaseBind

use of com.zx.sms.codec.smpp.msg.BaseBind in project SMSGate by Lihuanghe.

the class SMPPSessionLoginManager method failedLogin.

@Override
protected void failedLogin(ChannelHandlerContext ctx, Object msg, long status) {
    if (msg instanceof BaseBind) {
        logger.error("Connected error status :{},msg : {}", status, msg);
        BaseBind message = (BaseBind) msg;
        // 认证失败
        PduResponse resp = message.createResponse();
        resp.setCommandStatus((int) SmppConstants.STATUS_BINDFAIL);
        ChannelFuture promise = ctx.writeAndFlush(resp);
        final ChannelHandlerContext finalctx = ctx;
        promise.addListener(new GenericFutureListener() {

            public void operationComplete(Future future) throws Exception {
                finalctx.close();
            }
        });
    } else {
        logger.error("connect msg type error : {}", msg);
        ctx.close();
    }
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) PduResponse(com.zx.sms.codec.smpp.msg.PduResponse) BaseBind(com.zx.sms.codec.smpp.msg.BaseBind) ChannelFuture(io.netty.channel.ChannelFuture) Future(io.netty.util.concurrent.Future) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) GenericFutureListener(io.netty.util.concurrent.GenericFutureListener) TlvConvertException(com.zx.sms.codec.smpp.TlvConvertException)

Example 3 with BaseBind

use of com.zx.sms.codec.smpp.msg.BaseBind in project SMSGate by Lihuanghe.

the class SMPPSessionLoginManager method doLoginSuccess.

@Override
protected void doLoginSuccess(ChannelHandlerContext ctx, EndpointEntity entity, Object message) {
    // 发送bind请求
    SMPPEndpointEntity smppentity = (SMPPEndpointEntity) entity;
    BaseBind bind = (BaseBind) message;
    BaseBindResp resp = (BaseBindResp) bind.createResponse();
    resp.setSystemId(bind.getSystemId());
    ctx.channel().writeAndFlush(resp);
}
Also used : SMPPEndpointEntity(com.zx.sms.connect.manager.smpp.SMPPEndpointEntity) BaseBindResp(com.zx.sms.codec.smpp.msg.BaseBindResp) BaseBind(com.zx.sms.codec.smpp.msg.BaseBind)

Example 4 with BaseBind

use of com.zx.sms.codec.smpp.msg.BaseBind in project SMSGate by Lihuanghe.

the class SMPPSessionLoginManager method createBindRequest.

private BaseBind createBindRequest(SMPPEndpointEntity entity) {
    BaseBind bind = null;
    if (entity.getChannelType() == ChannelType.DUPLEX) {
        bind = new BindTransceiver();
    } else if (entity.getChannelType() == ChannelType.UP) {
        bind = new BindReceiver();
    } else if (entity.getChannelType() == ChannelType.DOWN) {
        bind = new BindTransmitter();
    } else {
        logger.error("Unable to convert SmppSessionConfiguration into a BaseBind request");
    }
    bind.setSystemId(entity.getSystemId());
    bind.setPassword(entity.getPassword());
    bind.setSystemType(entity.getSystemType());
    bind.setInterfaceVersion(entity.getInterfaceVersion());
    bind.setAddressRange(entity.getAddressRange());
    return bind;
}
Also used : BindTransceiver(com.zx.sms.codec.smpp.msg.BindTransceiver) BindReceiver(com.zx.sms.codec.smpp.msg.BindReceiver) BindTransmitter(com.zx.sms.codec.smpp.msg.BindTransmitter) BaseBind(com.zx.sms.codec.smpp.msg.BaseBind)

Example 5 with BaseBind

use of com.zx.sms.codec.smpp.msg.BaseBind in project SMSGate by Lihuanghe.

the class SMPPSessionLoginManager method validClientMsg.

@Override
protected int validClientMsg(EndpointEntity entity, Object msg) {
    SMPPEndpointEntity smppentity = (SMPPEndpointEntity) entity;
    BaseBind message = (BaseBind) msg;
    if (smppentity.getSystemId().equals(message.getSystemId()) && smppentity.getPassword().equals(message.getPassword())) {
        return 0;
    } else {
        return 3;
    }
}
Also used : SMPPEndpointEntity(com.zx.sms.connect.manager.smpp.SMPPEndpointEntity) BaseBind(com.zx.sms.codec.smpp.msg.BaseBind)

Aggregations

BaseBind (com.zx.sms.codec.smpp.msg.BaseBind)6 SMPPEndpointEntity (com.zx.sms.connect.manager.smpp.SMPPEndpointEntity)4 BindReceiver (com.zx.sms.codec.smpp.msg.BindReceiver)2 BindTransceiver (com.zx.sms.codec.smpp.msg.BindTransceiver)2 BindTransmitter (com.zx.sms.codec.smpp.msg.BindTransmitter)2 TlvConvertException (com.zx.sms.codec.smpp.TlvConvertException)1 BaseBindResp (com.zx.sms.codec.smpp.msg.BaseBindResp)1 PduResponse (com.zx.sms.codec.smpp.msg.PduResponse)1 EndpointEntity (com.zx.sms.connect.manager.EndpointEntity)1 SMPPServerEndpointEntity (com.zx.sms.connect.manager.smpp.SMPPServerEndpointEntity)1 ChannelFuture (io.netty.channel.ChannelFuture)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 Future (io.netty.util.concurrent.Future)1 GenericFutureListener (io.netty.util.concurrent.GenericFutureListener)1