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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations