Search in sources :

Example 1 with SessionTerminationRequestImpl

use of org.mobicents.slee.resource.diameter.rx.events.SessionTerminationRequestImpl in project jain-slee.diameter by RestComm.

the class RxMessageFactoryImpl method createDiameterMessage.

protected DiameterMessage createDiameterMessage(DiameterHeader diameterHeader, DiameterAvp[] avps, int _commandCode, ApplicationId appId) throws IllegalArgumentException {
    boolean creatingRequest = diameterHeader == null;
    Message msg = null;
    if (!creatingRequest) {
        Message raw = createMessage(diameterHeader, avps, 0, appId);
        raw.setRequest(false);
        // just in case. answers never have T flag set
        raw.setReTransmitted(false);
        msg = raw;
    } else {
        Message raw = createMessage(diameterHeader, avps, _commandCode, appId);
        raw.setRequest(true);
        msg = raw;
    }
    int commandCode = creatingRequest ? _commandCode : diameterHeader.getCommandCode();
    DiameterMessage diamMessage = null;
    switch(commandCode) {
        case AARequest.commandCode:
            diamMessage = creatingRequest ? new AARequestImpl(msg) : new AAAnswerImpl(msg);
            break;
        case Message.ABORT_SESSION_REQUEST:
            diamMessage = creatingRequest ? new AbortSessionRequestImpl(msg) : new AbortSessionAnswerImpl(msg);
            break;
        case Message.RE_AUTH_REQUEST:
            diamMessage = creatingRequest ? new ReAuthRequestImpl(msg) : new ReAuthAnswerImpl(msg);
            break;
        case Message.SESSION_TERMINATION_REQUEST:
            diamMessage = creatingRequest ? new SessionTerminationRequestImpl(msg) : new SessionTerminationAnswerImpl(msg);
            break;
        default:
            throw new IllegalArgumentException();
    }
    // Finally, add Origin-Host and Origin-Realm, if not present.
    addOriginHostAndRealm(diamMessage);
    return diamMessage;
}
Also used : Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) AbortSessionAnswerImpl(org.mobicents.slee.resource.diameter.rx.events.AbortSessionAnswerImpl) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) ReAuthRequestImpl(org.mobicents.slee.resource.diameter.rx.events.ReAuthRequestImpl) AbortSessionRequestImpl(org.mobicents.slee.resource.diameter.rx.events.AbortSessionRequestImpl) SessionTerminationAnswerImpl(org.mobicents.slee.resource.diameter.rx.events.SessionTerminationAnswerImpl) AAAnswerImpl(org.mobicents.slee.resource.diameter.rx.events.AAAnswerImpl) ReAuthAnswerImpl(org.mobicents.slee.resource.diameter.rx.events.ReAuthAnswerImpl) AARequestImpl(org.mobicents.slee.resource.diameter.rx.events.AARequestImpl) SessionTerminationRequestImpl(org.mobicents.slee.resource.diameter.rx.events.SessionTerminationRequestImpl)

Example 2 with SessionTerminationRequestImpl

use of org.mobicents.slee.resource.diameter.rx.events.SessionTerminationRequestImpl in project jain-slee.diameter by RestComm.

the class DiameterRxResourceAdaptor method createEvent.

/**
 * Create Event object from a JDiameter message (request or answer).
 *
 * @return a DiameterMessage object wrapping the request/answer
 * @throws OperationNotSupportedException
 */
private DiameterMessage createEvent(final Message message) {
    if (message == null) {
        throw new NullPointerException("Message argument cannot be null while creating event.");
    }
    final int commandCode = message.getCommandCode();
    if (message.isError()) {
        return new ErrorAnswerImpl(message);
    }
    final boolean isRequest = message.isRequest();
    switch(commandCode) {
        case // AAR/AAA
        AARequest.commandCode:
            return isRequest ? new AARequestImpl(message) : new AAAnswerImpl(message);
        case // ASR/ASA
        AbortSessionAnswer.commandCode:
            return isRequest ? new AbortSessionRequestImpl(message) : new AbortSessionAnswerImpl(message);
        case // STR/STA
        SessionTerminationAnswer.commandCode:
            return isRequest ? new SessionTerminationRequestImpl(message) : new SessionTerminationAnswerImpl(message);
        case // RAR/RAA
        ReAuthAnswer.commandCode:
            return isRequest ? new ReAuthRequestImpl(message) : new ReAuthAnswerImpl(message);
        default:
            return new ExtensionDiameterMessageImpl(message);
    }
}
Also used : AbortSessionAnswerImpl(org.mobicents.slee.resource.diameter.rx.events.AbortSessionAnswerImpl) ExtensionDiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl) SleeEndpoint(javax.slee.resource.SleeEndpoint) ReAuthRequestImpl(org.mobicents.slee.resource.diameter.rx.events.ReAuthRequestImpl) AbortSessionRequestImpl(org.mobicents.slee.resource.diameter.rx.events.AbortSessionRequestImpl) SessionTerminationAnswerImpl(org.mobicents.slee.resource.diameter.rx.events.SessionTerminationAnswerImpl) AAAnswerImpl(org.mobicents.slee.resource.diameter.rx.events.AAAnswerImpl) ReAuthAnswerImpl(org.mobicents.slee.resource.diameter.rx.events.ReAuthAnswerImpl) ErrorAnswerImpl(org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl) AARequestImpl(org.mobicents.slee.resource.diameter.rx.events.AARequestImpl) SessionTerminationRequestImpl(org.mobicents.slee.resource.diameter.rx.events.SessionTerminationRequestImpl)

Aggregations

AAAnswerImpl (org.mobicents.slee.resource.diameter.rx.events.AAAnswerImpl)2 AARequestImpl (org.mobicents.slee.resource.diameter.rx.events.AARequestImpl)2 AbortSessionAnswerImpl (org.mobicents.slee.resource.diameter.rx.events.AbortSessionAnswerImpl)2 AbortSessionRequestImpl (org.mobicents.slee.resource.diameter.rx.events.AbortSessionRequestImpl)2 ReAuthAnswerImpl (org.mobicents.slee.resource.diameter.rx.events.ReAuthAnswerImpl)2 ReAuthRequestImpl (org.mobicents.slee.resource.diameter.rx.events.ReAuthRequestImpl)2 SessionTerminationAnswerImpl (org.mobicents.slee.resource.diameter.rx.events.SessionTerminationAnswerImpl)2 SessionTerminationRequestImpl (org.mobicents.slee.resource.diameter.rx.events.SessionTerminationRequestImpl)2 SleeEndpoint (javax.slee.resource.SleeEndpoint)1 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)1 Message (org.jdiameter.api.Message)1 ErrorAnswerImpl (org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl)1 ExtensionDiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl)1