use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.
the class DiameterMessageFactoryImpl method createAccountingRequest.
public AccountingRequest createAccountingRequest(DiameterAvp[] avps) throws AvpNotAllowedException {
ApplicationId appId = getApplicationId(avps);
AccountingRequest msg = (AccountingRequest) this.createDiameterMessage(null, avps, Message.ACCOUNTING_REQUEST, appId != null ? appId : BASE_ACCT_APP_ID);
// Add Session-Id AVP if not present
addSessionIdAvp(msg);
return msg;
}
use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.
the class DiameterMessageFactoryImpl method getApplicationId.
private ApplicationId getApplicationId(DiameterAvp[] avps) {
ApplicationId applicationId = null;
long vendorId = 0L;
// Try to get Application-Id from Message AVPs
if (avps != null) {
for (DiameterAvp avp : avps) {
if (avp.getCode() == DiameterAvpCodes.VENDOR_ID) {
vendorId = avp.intValue();
}
if (avp.getCode() == DiameterAvpCodes.VENDOR_SPECIFIC_APPLICATION_ID) {
applicationId = getApplicationId(((GroupedAvp) avp).getExtensionAvps());
break;
}
if (avp.getCode() == DiameterAvpCodes.ACCT_APPLICATION_ID) {
applicationId = ApplicationId.createByAccAppId(vendorId, avp.intValue());
break;
} else if (avp.getCode() == DiameterAvpCodes.AUTH_APPLICATION_ID) {
applicationId = ApplicationId.createByAuthAppId(vendorId, avp.intValue());
break;
}
}
}
return applicationId;
}
use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.
the class AccountingSessionFactory method registerListener.
public void registerListener(DiameterRAInterface ra, long messageTimeout, SessionFactory sessionFactory) {
for (ApplicationId appId : ra.getSupportedApplications()) {
this.ras.put(appId, ra);
}
this.messageTimeout = messageTimeout;
this.sessionFactory = sessionFactory;
super.setSessionFactory((ISessionFactory) sessionFactory);
}
use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.
the class AccountingSessionFactory method doFireEvent.
private void doFireEvent(AppSession appSession, Message message) {
ApplicationId appId = null;
for (ApplicationId curAppId : message.getApplicationIdAvps()) {
if (curAppId.getAcctAppId() != ApplicationId.UNDEFINED_VALUE && this.ras.containsKey(curAppId)) {
appId = curAppId;
break;
}
}
DiameterRAInterface ra = appId != null ? this.ras.get(appId) : this.ras.values().iterator().next();
if (ra != null) {
ra.fireEvent(appSession.getSessions().get(0).getSessionId(), message);
} else {
// TODO: tracer
}
}
use of org.jdiameter.api.ApplicationId in project jain-slee.diameter by RestComm.
the class DiameterBaseResourceAdaptor method initStack.
// Private Methods -----------------------------------------------------
/**
* Initializes the RA Diameter Stack.
*
* @throws Exception
*/
private synchronized void initStack() throws Exception {
// Register in the Mux as app listener.
List<ApplicationId> allAppIds = new ArrayList<ApplicationId>();
allAppIds.addAll(authApplicationIds);
allAppIds.addAll(acctApplicationIds);
this.diameterMux.registerListener(this, allAppIds.toArray(new ApplicationId[allAppIds.size()]));
// Get the stack (should not mess with)
this.stack = this.diameterMux.getStack();
this.messageTimeout = stack.getMetaData().getConfiguration().getLongValue(MessageTimeOut.ordinal(), (Long) MessageTimeOut.defValue());
// Obtain parser and store it in AvpUtilities
MessageParser parser = ((IContainer) stack).getAssemblerFacility().getComponentInstance(MessageParser.class);
AvpUtilities.setParser(parser);
AvpUtilities.setDictionary(stack.getDictionary());
if (tracer.isInfoEnabled()) {
tracer.info("Diameter Base RA :: Successfully initialized stack.");
}
}
Aggregations