Search in sources :

Example 21 with Message

use of org.jdiameter.api.Message in project jain-slee.diameter by RestComm.

the class ShServerMessageFactoryImpl method createPushNotificationRequest.

public PushNotificationRequest createPushNotificationRequest() {
    List<DiameterAvp> avps = new ArrayList<DiameterAvp>();
    if (session != null)
        try {
            DiameterAvp sessionIdAvp = null;
            sessionIdAvp = localFactory.getBaseFactory().createAvp(0, DiameterAvpCodes.SESSION_ID, session.getSessionId());
            avps.add(sessionIdAvp);
        } catch (NoSuchAvpException e) {
            logger.error("Unable to create Session-Id AVP.", e);
        }
    Message msg = createShMessage(null, avps.toArray(new DiameterAvp[avps.size()]));
    PushNotificationRequestImpl request = new PushNotificationRequestImpl(msg);
    addOrigin(request);
    return request;
}
Also used : Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) PushNotificationRequestImpl(org.mobicents.slee.resource.diameter.sh.events.PushNotificationRequestImpl) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) ArrayList(java.util.ArrayList) NoSuchAvpException(net.java.slee.resource.diameter.base.NoSuchAvpException)

Example 22 with Message

use of org.jdiameter.api.Message in project jain-slee.diameter by RestComm.

the class ShServerMessageFactoryImpl method createSubscribeNotificationsAnswer.

public SubscribeNotificationsAnswer createSubscribeNotificationsAnswer(SubscribeNotificationsRequest request) {
    // Message msg = createShMessage(UserDataAnswer.commandCode, session !=
    // null ? session.getSessionId() : null, false);
    List<DiameterAvp> avps = new ArrayList<DiameterAvp>();
    DiameterAvp sessionIdAvp = null;
    try {
        sessionIdAvp = localFactory.getBaseFactory().createAvp(0, DiameterAvpCodes.SESSION_ID, request.getSessionId());
        avps.add(sessionIdAvp);
    } catch (NoSuchAvpException e) {
        logger.error("Unable to create Session-Id AVP.", e);
    }
    if (request.getUserIdentity() != null) {
        avps.add(request.getUserIdentity());
    }
    Message msg = createShMessage(request.getHeader(), avps.toArray(new DiameterAvp[avps.size()]));
    SubscribeNotificationsAnswerImpl answer = new SubscribeNotificationsAnswerImpl(msg);
    answer.setRouteRecords(request.getRouteRecords());
    // add more :) ?
    addOrigin(answer);
    return answer;
}
Also used : SubscribeNotificationsAnswerImpl(org.mobicents.slee.resource.diameter.sh.events.SubscribeNotificationsAnswerImpl) Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) ArrayList(java.util.ArrayList) NoSuchAvpException(net.java.slee.resource.diameter.base.NoSuchAvpException)

Example 23 with Message

use of org.jdiameter.api.Message in project jain-slee.diameter by RestComm.

the class ShClientMessageFactoryImpl method createPushNotificationAnswer.

public PushNotificationAnswer createPushNotificationAnswer(PushNotificationRequest request) {
    DiameterAvp[] avps = new DiameterAvp[0];
    try {
        DiameterAvp sessionIdAvp = null;
        sessionIdAvp = baseAvpFactory.createAvp(0, DiameterAvpCodes.SESSION_ID, request.getSessionId());
        avps = new DiameterAvp[] { sessionIdAvp };
    } catch (NoSuchAvpException e) {
        logger.error("Unexpected failure trying to create Session-Id AVP.", e);
    }
    Message msg = createShMessage(request.getHeader(), avps, PushNotificationAnswer.commandCode);
    PushNotificationAnswerImpl pna = new PushNotificationAnswerImpl(msg);
    addOrigin(pna);
    return pna;
}
Also used : Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) NoSuchAvpException(net.java.slee.resource.diameter.base.NoSuchAvpException) PushNotificationAnswerImpl(org.mobicents.slee.resource.diameter.sh.events.PushNotificationAnswerImpl)

Example 24 with Message

use of org.jdiameter.api.Message in project jain-slee.diameter by RestComm.

the class ShClientMessageFactoryImpl method createProfileUpdateRequest.

public ProfileUpdateRequest createProfileUpdateRequest() {
    DiameterAvp[] avps = new DiameterAvp[0];
    if (session != null) {
        try {
            DiameterAvp sessionIdAvp = null;
            sessionIdAvp = baseAvpFactory.createAvp(0, DiameterAvpCodes.SESSION_ID, session.getSessionId());
            avps = new DiameterAvp[] { sessionIdAvp };
        } catch (NoSuchAvpException e) {
            logger.error("Unexpected failure trying to create Session-Id AVP.", e);
        }
    }
    Message msg = createShMessage(null, avps, ProfileUpdateRequest.commandCode);
    ProfileUpdateRequestImpl pur = new ProfileUpdateRequestImpl(msg);
    addOrigin(pur);
    return pur;
}
Also used : ProfileUpdateRequestImpl(org.mobicents.slee.resource.diameter.sh.events.ProfileUpdateRequestImpl) Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) NoSuchAvpException(net.java.slee.resource.diameter.base.NoSuchAvpException)

Example 25 with Message

use of org.jdiameter.api.Message in project jain-slee.diameter by RestComm.

the class ShClientMessageFactoryImpl method createMessage.

protected Message createMessage(DiameterHeader header, DiameterAvp[] avps, int commandCode) throws AvpNotAllowedException {
    try {
        Message msg = createRawMessage(header, commandCode);
        AvpSet set = msg.getAvps();
        for (DiameterAvp avp : avps) {
            addAvp(avp, set);
        }
        return msg;
    } catch (Exception e) {
        logger.error("Unexpected failure trying to create Sh Message.", e);
    }
    return null;
}
Also used : Message(org.jdiameter.api.Message) DiameterMessage(net.java.slee.resource.diameter.base.events.DiameterMessage) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) AvpSet(org.jdiameter.api.AvpSet) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) InternalException(org.jdiameter.api.InternalException) IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException) NoSuchAvpException(net.java.slee.resource.diameter.base.NoSuchAvpException)

Aggregations

Message (org.jdiameter.api.Message)61 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)56 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)22 NoSuchAvpException (net.java.slee.resource.diameter.base.NoSuchAvpException)10 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)10 AvpSet (org.jdiameter.api.AvpSet)8 ArrayList (java.util.ArrayList)7 IllegalDiameterStateException (org.jdiameter.api.IllegalDiameterStateException)7 InternalException (org.jdiameter.api.InternalException)7 ErrorAnswerImpl (org.mobicents.slee.resource.diameter.base.events.ErrorAnswerImpl)7 GxCreditControlMessage (net.java.slee.resource.diameter.gx.events.GxCreditControlMessage)5 GxReAuthMessage (net.java.slee.resource.diameter.gx.events.GxReAuthMessage)5 RoCreditControlMessage (net.java.slee.resource.diameter.ro.events.RoCreditControlMessage)4 DiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)4 ExtensionDiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.ExtensionDiameterMessageImpl)4 IOException (java.io.IOException)3 AccountingAnswerImpl (org.mobicents.slee.resource.diameter.base.events.AccountingAnswerImpl)3 GqAARequestImpl (org.mobicents.slee.resource.diameter.gq.events.GqAARequestImpl)3 GqAbortSessionRequestImpl (org.mobicents.slee.resource.diameter.gq.events.GqAbortSessionRequestImpl)3 GqReAuthRequestImpl (org.mobicents.slee.resource.diameter.gq.events.GqReAuthRequestImpl)3