use of org.mobicents.slee.resource.diameter.rf.events.RfAccountingAnswerImpl in project jain-slee.diameter by RestComm.
the class RfMessageFactoryImpl method createRfAccountingMessage.
protected RfAccountingMessage createRfAccountingMessage(DiameterHeader diameterHeader, DiameterAvp[] avps) throws IllegalArgumentException {
// List<DiameterAvp> list = (List<DiameterAvp>) this.avpList.clone();
boolean isRequest = diameterHeader == null;
RfAccountingMessage msg = null;
if (!isRequest) {
Message raw = createMessage(diameterHeader, avps);
raw.setProxiable(diameterHeader.isProxiable());
raw.setRequest(false);
// just in case. answers never have T flag set
raw.setReTransmitted(false);
msg = new RfAccountingAnswerImpl(raw);
} else {
Message raw = createMessage(null, avps);
raw.setProxiable(true);
raw.setRequest(true);
msg = new RfAccountingRequestImpl(raw);
}
return msg;
}
use of org.mobicents.slee.resource.diameter.rf.events.RfAccountingAnswerImpl in project jain-slee.diameter by RestComm.
the class RfServerSessionActivityImpl method createRfAccountingAnswer.
public RfAccountingAnswer createRfAccountingAnswer(RfAccountingRequest request) {
try {
// Extract interesting AVPs
ArrayList<DiameterAvp> copyAvps = new ArrayList<DiameterAvp>();
copyAvps.add(avpFactory.createAvp(Avp.SESSION_ID, serverSession.getSessions().get(0).getSessionId()));
copyAvps.add(avpFactory.createAvp(Avp.ORIGIN_HOST, this.originHost.getBytes()));
copyAvps.add(avpFactory.createAvp(Avp.ORIGIN_REALM, this.originRealm.getBytes()));
for (DiameterAvp avp : request.getAvps()) {
if (avp.getCode() == Avp.ACC_RECORD_NUMBER || avp.getCode() == Avp.ACC_RECORD_TYPE) /* ||
avp.getCode() == Avp.ACCT_APPLICATION_ID || avp.getCode() == Avp.VENDOR_SPECIFIC_APPLICATION_ID*/
{
copyAvps.add((DiameterAvp) avp.clone());
}
}
RfAccountingAnswerImpl answer = (RfAccountingAnswerImpl) ((RfMessageFactoryImpl) rfMessageFactory).createRfAccountingMessage(request.getHeader(), copyAvps.toArray(new DiameterAvp[copyAvps.size()]));
// Get the raw Answer
Message rawAnswer = answer.getGenericData();
// This is an answer.
rawAnswer.setRequest(false);
// just in case. answers never have T flag set
rawAnswer.setReTransmitted(false);
answer.setData(request);
return answer;
} catch (Exception e) {
logger.error("", e);
}
return null;
}
use of org.mobicents.slee.resource.diameter.rf.events.RfAccountingAnswerImpl in project jain-slee.diameter by RestComm.
the class RfServerSessionActivityImpl method sendRfAccountingAnswer.
public void sendRfAccountingAnswer(RfAccountingAnswer answer) throws IOException {
try {
RfAccountingAnswerImpl aca = (RfAccountingAnswerImpl) answer;
this.serverSession.sendAccountAnswer(new org.jdiameter.common.impl.app.rf.RfAccountingAnswerImpl((Answer) aca.getGenericData()));
// FIXME: check this?
if (isTerminateAfterProcessing()) {
endActivity();
// this.serverSession.release();
//
// if(!serverSession.isValid()) {
// String sessionId =
// this.serverSession.getSessions().get(0).getSessionId();
// this.baseListener.sessionDestroyed(sessionId,
// this.serverSession);
// }
}
// clean
clean(aca);
} catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to send message, due to: ", e);
}
throw new IOException("Failed to send message, due to: " + e.getMessage());
}
}
use of org.mobicents.slee.resource.diameter.rf.events.RfAccountingAnswerImpl in project jain-slee.diameter by RestComm.
the class DiameterRfResourceAdaptor 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(Message message) {
if (message == null) {
throw new NullPointerException("Message argument cannot be null while creating event.");
}
int commandCode = message.getCommandCode();
if (message.isError()) {
return new ErrorAnswerImpl(message);
}
boolean isRequest = message.isRequest();
switch(commandCode) {
case // ACR/ACA
RfAccountingAnswer.commandCode:
return isRequest ? new RfAccountingRequestImpl(message) : new RfAccountingAnswerImpl(message);
default:
return new ExtensionDiameterMessageImpl(message);
}
}
Aggregations