use of net.java.slee.resource.diameter.base.events.DiameterMessage in project jain-slee.diameter by RestComm.
the class CxDxMessageFactoryImpl method createCxDxMessage.
/**
* Creates a CxDx Message with specified command-code and avps filled. If a header is present an answer will be created, if not
* it will generate a request.
*
* @param diameterHeader
* @param avps
* @param _commandCode
* @param appId
* @return
* @throws InternalException
*/
DiameterMessage createCxDxMessage(DiameterHeader diameterHeader, DiameterAvp[] avps, int _commandCode, ApplicationId appId) throws InternalException {
boolean creatingRequest = diameterHeader == null;
Message msg = null;
if (!creatingRequest) {
Message raw = createMessage(diameterHeader, avps, 0, appId);
raw.setProxiable(diameterHeader.isProxiable());
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.setProxiable(true);
raw.setRequest(true);
msg = raw;
}
int commandCode = creatingRequest ? _commandCode : diameterHeader.getCommandCode();
DiameterMessage diamMessage = null;
switch(commandCode) {
case LocationInfoRequest.COMMAND_CODE:
diamMessage = creatingRequest ? new LocationInfoRequestImpl(msg) : new LocationInfoAnswerImpl(msg);
break;
case MultimediaAuthenticationRequest.COMMAND_CODE:
diamMessage = creatingRequest ? new MultimediaAuthenticationRequestImpl(msg) : new MultimediaAuthenticationAnswerImpl(msg);
break;
case PushProfileRequest.COMMAND_CODE:
diamMessage = creatingRequest ? new PushProfileRequestImpl(msg) : new PushProfileAnswerImpl(msg);
break;
case RegistrationTerminationRequest.COMMAND_CODE:
diamMessage = creatingRequest ? new RegistrationTerminationRequestImpl(msg) : new RegistrationTerminationAnswerImpl(msg);
break;
case ServerAssignmentRequest.COMMAND_CODE:
diamMessage = creatingRequest ? new ServerAssignmentRequestImpl(msg) : new ServerAssignmentAnswerImpl(msg);
break;
case UserAuthorizationRequest.COMMAND_CODE:
diamMessage = creatingRequest ? new UserAuthorizationRequestImpl(msg) : new UserAuthorizationAnswerImpl(msg);
break;
default:
diamMessage = new ExtensionDiameterMessageImpl(msg);
}
if (!diamMessage.hasSessionId() && session != null) {
diamMessage.setSessionId(session.getSessionId());
}
return diamMessage;
}
use of net.java.slee.resource.diameter.base.events.DiameterMessage in project jain-slee.diameter by RestComm.
the class DiameterMessageFactoryImpl 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.setProxiable(true);
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);
boolean isPeerManagementMessage = _commandCode == CapabilitiesExchangeRequest.commandCode || _commandCode == DeviceWatchdogRequest.commandCode || _commandCode == DisconnectPeerRequest.commandCode;
raw.setProxiable(!isPeerManagementMessage);
raw.setRequest(true);
msg = raw;
}
int commandCode = creatingRequest ? _commandCode : diameterHeader.getCommandCode();
DiameterMessage diamMessage = null;
switch(commandCode) {
case Message.ABORT_SESSION_REQUEST:
diamMessage = creatingRequest ? new AbortSessionRequestImpl(msg) : new AbortSessionAnswerImpl(msg);
break;
case Message.ACCOUNTING_REQUEST:
diamMessage = creatingRequest ? new AccountingRequestImpl(msg) : new AccountingAnswerImpl(msg);
break;
case Message.CAPABILITIES_EXCHANGE_REQUEST:
diamMessage = creatingRequest ? new CapabilitiesExchangeRequestImpl(msg) : new CapabilitiesExchangeAnswerImpl(msg);
break;
case Message.DEVICE_WATCHDOG_REQUEST:
diamMessage = creatingRequest ? new DeviceWatchdogRequestImpl(msg) : new DeviceWatchdogAnswerImpl(msg);
break;
case Message.DISCONNECT_PEER_REQUEST:
diamMessage = creatingRequest ? new DisconnectPeerRequestImpl(msg) : new DisconnectPeerAnswerImpl(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:
diamMessage = new ExtensionDiameterMessageImpl(msg);
}
// Finally, add Origin-Host and Origin-Realm, if not present.
addOriginHostAndRealm(diamMessage);
return diamMessage;
}
use of net.java.slee.resource.diameter.base.events.DiameterMessage in project jain-slee.diameter by RestComm.
the class DiameterCCAResourceAdaptor method fireEvent.
public void fireEvent(String sessionId, Message message) {
DiameterMessage event = (DiameterMessage) createEvent(message);
FireableEventType eventId = eventIdCache.getEventId(eventLookup, message);
this.fireEvent(event, getActivityHandle(sessionId), eventId, null, true, message.isRequest());
}
use of net.java.slee.resource.diameter.base.events.DiameterMessage in project jain-slee.diameter by RestComm.
the class DiameterCxDxResourceAdaptor method fireEvent.
/*
* (non-Javadoc)
* @see org.mobicents.slee.resource.diameter.base.handlers.BaseSessionCreationListener#fireEvent(java.lang.String, org.jdiameter.api.Request, org.jdiameter.api.Answer)
*/
public void fireEvent(String sessionId, Message message) {
DiameterMessage event = (DiameterMessage) createEvent(message);
FireableEventType eventId = eventIdCache.getEventId(eventLookup, message);
this.fireEvent(event, getActivityHandle(sessionId), eventId, null, true, message.isRequest());
}
use of net.java.slee.resource.diameter.base.events.DiameterMessage in project jain-slee.diameter by RestComm.
the class GxSessionActivityImpl method sendSyncMessage.
@Override
public DiameterMessage sendSyncMessage(DiameterMessage message) {
DiameterMessage answer = null;
Message receivedMessage = doSendMessage(message);
if (receivedMessage != null) {
if (!receivedMessage.isRequest()) {
if (receivedMessage.isError()) {
answer = new ErrorAnswerImpl(receivedMessage);
} else {
switch(receivedMessage.getCommandCode()) {
case GxCreditControlRequest.commandCode:
answer = new GxCreditControlRequestImpl(receivedMessage);
break;
case GxReAuthRequest.commandCode:
answer = new GxReAuthRequestImpl(receivedMessage);
break;
default:
logger.error("Received an unknown type of Message for Gx Activity: " + receivedMessage);
break;
}
}
} else {
logger.error("Received a REQUEST message when expecting an ANSWER.");
}
} else {
logger.debug("No answer received. Returning null.");
}
return answer;
}
Aggregations