Search in sources :

Example 11 with UnrecoverablePduException

use of com.cloudhopper.smpp.type.UnrecoverablePduException in project load-balancer by RestComm.

the class ServerConnectionImpl method sendUnbindResponse.

@Override
public void sendUnbindResponse(Pdu packet) {
    enquireRunnable.cancel();
    enquireTimer.cancel(false);
    if (packetMap.containsKey(packet.getSequenceNumber())) {
        TimerData data = packetMap.remove(packet.getSequenceNumber());
        if (data != null) {
            data.getRunnable().cancel();
            data.getScheduledFuture().cancel(false);
        }
    }
    ChannelBuffer buffer = null;
    try {
        buffer = transcoder.encode(packet);
    } catch (UnrecoverablePduException e) {
        logger.error("Encode error: ", e);
    } catch (RecoverablePduException e) {
        logger.error("Encode error: ", e);
    }
    serverState = ServerState.CLOSED;
    packetMap.clear();
    sequenceMap.clear();
    if (logger.isDebugEnabled())
        logger.debug("LB sent  unbind response (" + packet + ") to " + channel.getRemoteAddress().toString() + ". session ID : " + sessionId);
    channel.write(buffer);
}
Also used : TimerData(org.mobicents.tools.smpp.balancer.timers.TimerData) RecoverablePduException(com.cloudhopper.smpp.type.RecoverablePduException) UnrecoverablePduException(com.cloudhopper.smpp.type.UnrecoverablePduException) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Example 12 with UnrecoverablePduException

use of com.cloudhopper.smpp.type.UnrecoverablePduException in project load-balancer by RestComm.

the class ServerConnectionImpl method sendGenericNack.

/**
 *Send generic_nack to client if unable to convert request
 *from client
 *@param packet PDU packet
 */
private void sendGenericNack(Pdu packet) {
    GenericNack genericNack = new GenericNack();
    genericNack.setSequenceNumber(packet.getSequenceNumber());
    genericNack.setCommandStatus(SmppConstants.STATUS_INVCMDID);
    ChannelBuffer buffer = null;
    try {
        buffer = transcoder.encode(genericNack);
    } catch (UnrecoverablePduException e) {
        logger.error("Encode error: ", e);
    } catch (RecoverablePduException e) {
        logger.error("Encode error: ", e);
    }
    if (logger.isDebugEnabled())
        logger.debug("LB sent generic_nack response for packet (" + packet + ") to " + channel.getRemoteAddress().toString() + ". session ID : " + sessionId);
    channel.write(buffer);
}
Also used : GenericNack(com.cloudhopper.smpp.pdu.GenericNack) RecoverablePduException(com.cloudhopper.smpp.type.RecoverablePduException) UnrecoverablePduException(com.cloudhopper.smpp.type.UnrecoverablePduException) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Example 13 with UnrecoverablePduException

use of com.cloudhopper.smpp.type.UnrecoverablePduException in project load-balancer by RestComm.

the class MClientConnectionImpl method sendSmppResponse.

@Override
public void sendSmppResponse(Pdu packet) {
    if (packetMap.containsKey(packet.getSequenceNumber())) {
        TimerData data = packetMap.remove(packet.getSequenceNumber());
        if (data != null) {
            data.getRunnable().cancel();
            data.getScheduledFuture().cancel(false);
        }
    }
    ChannelBuffer buffer = null;
    try {
        buffer = transcoder.encode(packet);
    } catch (UnrecoverablePduException e) {
        logger.error("Encode error: ", e);
    } catch (RecoverablePduException e) {
        logger.error("Encode error: ", e);
    }
    if (logger.isDebugEnabled())
        logger.debug("LB sent SMPP response (" + packet + ") to client " + channel.getRemoteAddress().toString() + ". client session ID : " + serverSessionID);
    channel.write(buffer);
}
Also used : TimerData(org.mobicents.tools.smpp.balancer.timers.TimerData) RecoverablePduException(com.cloudhopper.smpp.type.RecoverablePduException) UnrecoverablePduException(com.cloudhopper.smpp.type.UnrecoverablePduException) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Example 14 with UnrecoverablePduException

use of com.cloudhopper.smpp.type.UnrecoverablePduException in project load-balancer by RestComm.

the class MClientConnectionImpl method bind.

@SuppressWarnings("rawtypes")
@Override
public void bind() {
    BaseBind packet = null;
    if (config.getType() == SmppBindType.TRANSCEIVER) {
        packet = new BindTransceiver();
    } else if (config.getType() == SmppBindType.RECEIVER) {
        packet = new BindReceiver();
    } else if (config.getType() == SmppBindType.TRANSMITTER) {
        packet = new BindTransmitter();
    }
    packet.setSystemId(config.getSystemId());
    packet.setPassword(config.getPassword());
    packet.setSystemType(config.getSystemType());
    packet.setInterfaceVersion(config.getInterfaceVersion());
    packet.setAddressRange(config.getAddressRange());
    packet.setSequenceNumber(lastSequenceNumberSent.incrementAndGet());
    ChannelBuffer buffer = null;
    try {
        buffer = transcoder.encode(packet);
    } catch (UnrecoverablePduException e) {
        logger.error("Encode error: ", e);
    } catch (RecoverablePduException e) {
        logger.error("Encode error: ", e);
    }
    if (clientState != ClientState.REBINDING)
        clientState = ClientState.BINDING;
    if (logger.isDebugEnabled())
        logger.debug("LB trying to bind to server " + config.getHost() + " " + config.getPort() + ": client state " + clientState);
    channel.write(buffer);
}
Also used : BindTransceiver(com.cloudhopper.smpp.pdu.BindTransceiver) BindReceiver(com.cloudhopper.smpp.pdu.BindReceiver) BindTransmitter(com.cloudhopper.smpp.pdu.BindTransmitter) BaseBind(com.cloudhopper.smpp.pdu.BaseBind) RecoverablePduException(com.cloudhopper.smpp.type.RecoverablePduException) UnrecoverablePduException(com.cloudhopper.smpp.type.UnrecoverablePduException) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Example 15 with UnrecoverablePduException

use of com.cloudhopper.smpp.type.UnrecoverablePduException in project load-balancer by RestComm.

the class MServerConnectionImpl method sendGenericNack.

/**
 *Send generic_nack to client if unable to convert request
 *from client
 *@param packet PDU packet
 */
private void sendGenericNack(Pdu packet) {
    GenericNack genericNack = new GenericNack();
    genericNack.setSequenceNumber(packet.getSequenceNumber());
    genericNack.setCommandStatus(SmppConstants.STATUS_INVCMDID);
    ChannelBuffer buffer = null;
    try {
        buffer = transcoder.encode(genericNack);
    } catch (UnrecoverablePduException e) {
        logger.error("Encode error: ", e);
    } catch (RecoverablePduException e) {
        logger.error("Encode error: ", e);
    }
    if (logger.isDebugEnabled())
        logger.debug("LB sent generic_nack response for packet (" + packet + ") to server " + channel.getRemoteAddress().toString() + ". session ID : " + sessionId);
    channel.write(buffer);
}
Also used : GenericNack(com.cloudhopper.smpp.pdu.GenericNack) RecoverablePduException(com.cloudhopper.smpp.type.RecoverablePduException) UnrecoverablePduException(com.cloudhopper.smpp.type.UnrecoverablePduException) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Aggregations

RecoverablePduException (com.cloudhopper.smpp.type.RecoverablePduException)26 UnrecoverablePduException (com.cloudhopper.smpp.type.UnrecoverablePduException)26 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)26 TimerData (org.mobicents.tools.smpp.balancer.timers.TimerData)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 EnquireLink (com.cloudhopper.smpp.pdu.EnquireLink)4 Pdu (com.cloudhopper.smpp.pdu.Pdu)4 BaseBind (com.cloudhopper.smpp.pdu.BaseBind)2 BindReceiver (com.cloudhopper.smpp.pdu.BindReceiver)2 BindTransceiver (com.cloudhopper.smpp.pdu.BindTransceiver)2 BindTransmitter (com.cloudhopper.smpp.pdu.BindTransmitter)2 GenericNack (com.cloudhopper.smpp.pdu.GenericNack)2 ServerTimerConnectionCheck (org.mobicents.tools.smpp.balancer.timers.ServerTimerConnectionCheck)1